Skip to content

Commit

Permalink
try if (not) exists
Browse files Browse the repository at this point in the history
  • Loading branch information
kathap committed Aug 26, 2024
1 parent 8a3a648 commit ffae27d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
up do
if self.class.name.match?(/mysql/i)
alter_table :quota_definitions do
drop_constraint :name
drop_constraint :name, if_exists: true
end
elsif self.class.name.match?(/postgres/i)
alter_table :quota_definitions do
drop_constraint :quota_definitions_name_key
drop_constraint :quota_definitions_name_key, if_exists: true
end
end
end
Expand All @@ -20,11 +20,11 @@
# rubocop:enable Sequel/ConcurrentIndex
end
alter_table :quota_definitions do
add_unique_constraint :name, name: :name
add_unique_constraint :name, name: :name, if_not_exists: true
end
elsif self.class.name.match?(/postgres/i)
alter_table :quota_definitions do
add_unique_constraint :name, name: :quota_definitions_name_key
add_unique_constraint :name, name: :quota_definitions_name_key, if_not_exists: true
end
end
end
Expand Down

0 comments on commit ffae27d

Please sign in to comment.