Skip to content

Commit f400883

Browse files
Fix tests for 7.1 (keeping retrocompatibility with v6)
1 parent b1d94e5 commit f400883

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

Gemfile.lock

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,32 @@ PATH
88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
activemodel (7.0.7.2)
12-
activesupport (= 7.0.7.2)
13-
activerecord (7.0.7.2)
14-
activemodel (= 7.0.7.2)
15-
activesupport (= 7.0.7.2)
16-
activesupport (7.0.7.2)
11+
activemodel (7.1.2)
12+
activesupport (= 7.1.2)
13+
activerecord (7.1.2)
14+
activemodel (= 7.1.2)
15+
activesupport (= 7.1.2)
16+
timeout (>= 0.4.0)
17+
activesupport (7.1.2)
18+
base64
19+
bigdecimal
1720
concurrent-ruby (~> 1.0, >= 1.0.2)
21+
connection_pool (>= 2.2.5)
22+
drb
1823
i18n (>= 1.6, < 2)
1924
minitest (>= 5.1)
25+
mutex_m
2026
tzinfo (~> 2.0)
2127
ast (2.4.2)
28+
base64 (0.2.0)
29+
bigdecimal (3.1.4)
2230
coderay (1.1.3)
2331
concurrent-ruby (1.2.2)
32+
connection_pool (2.4.1)
2433
coolline (0.5.0)
2534
unicode_utils (~> 1.4)
35+
drb (2.2.0)
36+
ruby2_keywords
2637
i18n (1.14.1)
2738
concurrent-ruby (~> 1.0)
2839
json (2.6.3)
@@ -31,6 +42,7 @@ GEM
3142
minitest (5.18.1)
3243
mocha (2.0.4)
3344
ruby2_keywords (>= 0.0.5)
45+
mutex_m (0.2.0)
3446
parallel (1.23.0)
3547
parser (3.2.2.3)
3648
ast (~> 2.4.1)
@@ -64,6 +76,7 @@ GEM
6476
ruby2_keywords (0.0.5)
6577
strong_migrations (1.4.3)
6678
activerecord (>= 5.2)
79+
timeout (0.4.1)
6780
tzinfo (2.0.6)
6881
concurrent-ruby (~> 1.0)
6982
unicode-display_width (2.4.2)

lib/safe-pg-migrations/plugins/idempotent_statements.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def add_column(table_name, column_name, type, **options)
2323
error_message = "/!\\ Column '#{column_name}' already exists in '#{table_name}' with a different type"
2424
raise error_message
2525
end
26-
27-
return super unless column_exists?(table_name, column_name, type)
26+
options_without_default_value_backfill = options.except(:default_value_backfill)
27+
return super(table_name, column_name, type, **options_without_default_value_backfill) unless column_exists?(table_name, column_name, type)
2828

2929
log_message(<<~MESSAGE.squish
3030
/!\\ Column '#{column_name}' already exists in '#{table_name}' with the same type (#{type}).
@@ -79,8 +79,9 @@ def create_table(table_name, *args)
7979
end
8080

8181
def add_check_constraint(table_name, expression, **options)
82+
options_without_validate = options.except(:validate)
8283
constraint_definition = check_constraint_for table_name,
83-
**check_constraint_options(table_name, expression, options)
84+
**check_constraint_options(table_name, expression, options_without_validate)
8485

8586
return super if constraint_definition.nil?
8687

lib/safe-pg-migrations/plugins/statement_insurer/add_column.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module AddColumn
66
def add_column(table_name, column_name, type, **options)
77
return super if should_keep_default_implementation?(**options)
88

9+
options.delete(:default_value_backfill)
10+
911
raise <<~ERROR unless backfill_column_default_safe?(table_name)
1012
Table #{table_name} has more than #{SafePgMigrations.config.default_value_backfill_threshold} rows.
1113
Backfilling the default value for column #{column_name} on table #{table_name} would take too long.

test/StatementInsurer/change_column_null_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def skip_if_unmet_requirements!
126126
end
127127

128128
def met_requirements?
129-
Gem::Requirement.new('>6.1', '<7.1').satisfied_by?(Gem::Version.new(::ActiveRecord::VERSION::STRING)) &&
129+
Gem::Requirement.new('>6.1').satisfied_by?(Gem::Version.new(::ActiveRecord::VERSION::STRING)) &&
130130
SafePgMigrations.pg_version_num >= 120_000
131131
end
132132
end

0 commit comments

Comments
 (0)