Skip to content

Commit

Permalink
fix pessimistic check constraints frd
Browse files Browse the repository at this point in the history
  • Loading branch information
ccutrer committed Sep 7, 2023
1 parent f4d96fc commit 5852d10
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
activerecord-pg-extensions (0.5.1)
activerecord-pg-extensions (0.5.2)
activerecord (~> 7.0.0)
railties (~> 7.0.0)

Expand Down
6 changes: 4 additions & 2 deletions lib/active_record/pg_extensions/pessimistic_migrations.rb
Expand Up @@ -90,14 +90,16 @@ def add_index(table_name, column_name, **options)
end

def add_check_constraint(table_name, expression, if_not_exists: false, **options)
return if if_not_exists && check_constraint_for(table_name, expression, **options)
options = check_constraint_options(table_name, expression, options)
return if if_not_exists && check_constraint_for(table_name, **options)

super
end

if ActiveRecord.version < Gem::Version.new("7.1")
def remove_check_constraint(table_name, expression = nil, if_exists: false, **options)
return if if_exists && !check_constraint_for(table_name, expression, **options)
options = check_constraint_options(table_name, expression, options)
return if if_exists && !check_constraint_for(table_name, **options)

super
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/pg_extensions/version.rb
Expand Up @@ -2,6 +2,6 @@

module ActiveRecord
module PGExtensions
VERSION = "0.5.1"
VERSION = "0.5.2"
end
end

0 comments on commit 5852d10

Please sign in to comment.