From 62b1980ca7a9c3c23fc8ce3b918e88f1d735cc01 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Fri, 6 Jan 2023 17:04:55 +0100 Subject: [PATCH] correct migration --- ...106130950_set_about_from_menu_item_kind.rb | 26 +++++++++---------- db/schema.rb | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) 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 e1bd0840f..3e43f8180 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 9a2e36617..0afdf7c29 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" -- GitLab