diff --git a/db/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key.rb b/db/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key.rb index 4bd8074c64e..ecf615dc8a1 100644 --- a/db/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key.rb +++ b/db/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key.rb @@ -2,6 +2,10 @@ up do if self.class.name.match?(/mysql/i) alter_table :quota_definitions do + # rubocop:disable Sequel/ConcurrentIndex + # mysql 5 is not so smart as mysql 8 + drop_index :name, name: :name if @db.indexes(:quota_definitions).include?(:name) + # rubocop:enable Sequel/ConcurrentIndex drop_constraint :name, if_exists: true end elsif self.class.name.match?(/postgres/i) diff --git a/spec/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key_spec.rb b/spec/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key_spec.rb index f15336878c3..a3558a36707 100644 --- a/spec/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key_spec.rb +++ b/spec/migrations/20240808118000_drop_unique_constraint_quota_definitions_name_key_spec.rb @@ -5,6 +5,7 @@ include_context 'migration' do let(:migration_filename) { '20240808118000_drop_unique_constraint_quota_definitions_name_key_spec.rb' } end + describe 'up migration' do context 'unique constraint on name column exists' do it 'removes the unique constraint' do