From 317c7b7e7fc69057c5a4b4727a1c5ac344cf1d24 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 12 Nov 2020 11:54:29 +0100 Subject: [PATCH] Maintenance: Redo column allow signup with reset column information to make the migration work. Removed old migration because of missing column information reset there was a quite crash. --- ...column.rb => 20201112000000_role_signup_column_fix.rb} | 8 ++++++-- spec/db/migrate/role_signup_column_spec.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) rename db/migrate/{20201005113317_role_signup_column.rb => 20201112000000_role_signup_column_fix.rb} (77%) diff --git a/db/migrate/20201005113317_role_signup_column.rb b/db/migrate/20201112000000_role_signup_column_fix.rb similarity index 77% rename from db/migrate/20201005113317_role_signup_column.rb rename to db/migrate/20201112000000_role_signup_column_fix.rb index adb4cd395..bfae46ada 100644 --- a/db/migrate/20201005113317_role_signup_column.rb +++ b/db/migrate/20201112000000_role_signup_column_fix.rb @@ -1,10 +1,14 @@ -class RoleSignupColumn < ActiveRecord::Migration[5.2] +class RoleSignupColumnFix < ActiveRecord::Migration[5.2] def change # return if it's a new setup return if !Setting.exists?(name: 'system_init_done') - add_column :permissions, :allow_signup, :boolean, null: false, default: false + if !column_exists?(:permissions, :allow_signup) + add_column :permissions, :allow_signup, :boolean, null: false, default: false + end + + Permission.reset_column_information signup_permissions = [ 'user_preferences', diff --git a/spec/db/migrate/role_signup_column_spec.rb b/spec/db/migrate/role_signup_column_spec.rb index 810a05e70..0b820b513 100644 --- a/spec/db/migrate/role_signup_column_spec.rb +++ b/spec/db/migrate/role_signup_column_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe RoleSignupColumn, type: :db_migration, db_strategy: :reset do +RSpec.describe RoleSignupColumnFix, type: :db_migration, db_strategy: :reset do context 'when a role contains signup permissions' do let!(:role) do role = create(:role)