diff --git a/db/migrate/20230106130950_set_about_from_menu_item_kind.rb b/db/migrate/20230106130950_set_about_from_menu_item_kind.rb index e1bd0840fada35fdc060d4c4fc13eb6a41eda298..3e43f81808dbf6e2d64ceca6214a7672bf89aa0c 100644 --- a/db/migrate/20230106130950_set_about_from_menu_item_kind.rb +++ b/db/migrate/20230106130950_set_about_from_menu_item_kind.rb @@ -1,22 +1,22 @@ class SetAboutFromMenuItemKind < ActiveRecord::Migration[7.0] def change mapping = { - 30: Communication::Website::Page::EducationProgram, - 32: Communication::Website::Page::EducationDiploma, - 40: Communication::Website::Page::CommunicationPost, - 45: Communication::Website::Page::Organization, - 50: Communication::Website::Page::Person, - 51: Communication::Website::Page::Administrator, - 52: Communication::Website::Page::Author, - 53: Communication::Website::Page::Researcher, - 54: Communication::Website::Page::Teacher, - 60: Communication::Website::Page::ResearchVolume, - 62: Communication::Website::Page::ResearchPaper + '30' => Communication::Website::Page::EducationProgram, + '32' => Communication::Website::Page::EducationDiploma, + '40' => Communication::Website::Page::CommunicationPost, + '45' => Communication::Website::Page::Organization, + '50' => Communication::Website::Page::Person, + '51' => Communication::Website::Page::Administrator, + '52' => Communication::Website::Page::Author, + '53' => Communication::Website::Page::Researcher, + '54' => Communication::Website::Page::Teacher, + '60' => Communication::Website::Page::ResearchVolume, + '62' => Communication::Website::Page::ResearchPaper } websites = Communication::Website.where(id: Communication::Website::Menu::Item.where(kind: mapping.keys).distinct.pluck(:website_id)) - Communication::Website::Menu::Item.includes(:website).where(kind: mapping.keys).find_each do |menu_item| - page_class = mapping[menu_item.kind.to_sym] + Communication::Website::Menu::Item.includes(:website).where(kind: mapping.keys.map(&:to_i)).find_each do |menu_item| + page_class = mapping[menu_item.kind_before_type_cast.to_s] about = menu_item.website.special_page(page_class) menu_item.update(about: about, kind: :page) end diff --git a/db/schema.rb b/db/schema.rb index 9a2e36617101db97dad4f372a5b9e346d195ed7d..0afdf7c295968f61853ebb0f5141d292a431fee6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_06_130950) do +ActiveRecord::Schema[7.0].define(version: 2023_01_06_132654) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql"