Skip to content

Commit

Permalink
adapt migration for mysql5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kathap committed Sep 2, 2024
1 parent 5e72cdd commit a061f4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Sequel.migration do
up do
if self.class.name.match?(/mysql/i)
mysql_version = server_version
if mysql_version < 80_000 # MySQL 5.7 and below
alter_table :quota_definitions do
# rubocop:disable Sequel/ConcurrentIndex
# Drop the index only for MySQL 5.7
drop_index :name, name: :name if @db.indexes(:quota_definitions).include?(:name)
# rubocop:enable Sequel/ConcurrentIndex
end
end
alter_table :quota_definitions do
drop_constraint :name, if_exists: true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a061f4a

Please sign in to comment.