From a67c6325199dd130503622a7e0f0e29ee2eb8c4c Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 4 Jun 2020 23:30:33 +0200 Subject: [PATCH 1/3] Do not seed while upgrading The Alchemy seeder does not need to run. --- lib/tasks/alchemy/upgrade.rake | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tasks/alchemy/upgrade.rake b/lib/tasks/alchemy/upgrade.rake index 17256f0db1..efb5f8fc87 100644 --- a/lib/tasks/alchemy/upgrade.rake +++ b/lib/tasks/alchemy/upgrade.rake @@ -24,7 +24,6 @@ namespace :alchemy do "alchemy:upgrade:5.0:remove_root_page", "alchemy:install:migrations", "db:migrate", - "alchemy:db:seed", ] desc "Alchemy Upgrader: Copy configuration file." From 9f18b952c03f61ea29a84ef2191146ab710e423a Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 4 Jun 2020 23:32:12 +0200 Subject: [PATCH 2/3] Fix the order of upgrade tasks If we run the dedecated 5.0 upgrade tasks before installing the migrations it will skip installing them. Since it is not harmfil to run the migrations before hand and this was the case for the upgrader all the time this fix should be considered fine. --- lib/tasks/alchemy/upgrade.rake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/tasks/alchemy/upgrade.rake b/lib/tasks/alchemy/upgrade.rake index efb5f8fc87..45c134dcc8 100644 --- a/lib/tasks/alchemy/upgrade.rake +++ b/lib/tasks/alchemy/upgrade.rake @@ -6,6 +6,7 @@ namespace :alchemy do desc "Upgrades your app to AlchemyCMS v#{Alchemy::VERSION}." task upgrade: [ "alchemy:upgrade:prepare", + "alchemy:upgrade:5.0:run", ] do Alchemy::Upgrader.display_todos end @@ -19,9 +20,6 @@ namespace :alchemy do desc "Alchemy Upgrader: Prepares the database." task database: [ - "alchemy:upgrade:5.0:install_gutentag_migrations", - "alchemy:upgrade:5.0:remove_layout_roots", - "alchemy:upgrade:5.0:remove_root_page", "alchemy:install:migrations", "db:migrate", ] @@ -34,11 +32,18 @@ namespace :alchemy do desc "Upgrade Alchemy to v5.0" task "5.0" => [ "alchemy:upgrade:prepare", + "alchemy:upgrade:5.0:run", ] do Alchemy::Upgrader.display_todos end namespace "5.0" do + task "run" => [ + "alchemy:upgrade:5.0:install_gutentag_migrations", + "alchemy:upgrade:5.0:remove_layout_roots", + "alchemy:upgrade:5.0:remove_root_page", + ] + desc "Install Gutentag migrations" task install_gutentag_migrations: [:environment] do Alchemy::Upgrader::FivePointZero.install_gutentag_migrations From daa78e32f9d83d1594cdf924e741aff614e6cba0 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 4 Jun 2020 23:37:40 +0200 Subject: [PATCH 3/3] Fix the add menu_type migration This migration fails being rolled back because change_column is not reversible. Using `change_column_null` resolves that issue. Also it does not make sense to write into a column we delete any way. --- .../20200511113603_add_menu_type_to_alchemy_nodes.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb b/db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb index f300d38fd2..258f31cae1 100644 --- a/db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb +++ b/db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb @@ -11,13 +11,17 @@ def self.root_for(node) end end - def change + def up add_column :alchemy_nodes, :menu_type, :string LocalNode.all.each do |node| root = LocalNode.root_for(node) menu_type = root.name.parameterize.underscore node.update(menu_type: menu_type) end - change_column :alchemy_nodes, :menu_type, :string, null: false + change_column_null :alchemy_nodes, :menu_type, false + end + + def down + remove_column :alchemy_nodes, :menu_type end end