Skip to content

Commit 7213f4b

Browse files
committed
Fix slop
I don't have a `safety_assured` method (thanks Opus!) I ran migrations locally to validate they worked, so something about my flow must have triggered a change before the actual commit. Deploying #1844 causes an error: ``` -- safety_assured(nil) D, [2026-02-02T15:53:04.496858 #1236] DEBUG -- : (1.4ms) SELECT pg_advisory_unlock(3010662050404357335) rake aborted! StandardError: An error has occurred, all later migrations canceled: (StandardError) undefined method `safety_assured' for #<ChangeIssuesIdToBigint:0x00007f10e6d28d10 @name="ChangeIssuesIdToBigint", @Version=20260202160000, @connection=nil> /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:964:in `block in method_missing' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:935:in `block in say_with_time' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:935:in `say_with_time' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:954:in `method_missing' /tmp/build_92292fc4/db/migrate/20260202160000_change_issues_id_to_bigint.rb:14:in `up' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:908:in `public_send' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:908:in `exec_migration' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:889:in `block (2 levels) in migrate' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/migration.rb:888:in `block in migrate' /tmp/build_92292fc4/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in ``` I think this wasn't caught in CI since it loads from schema first instead of running all migrations.
1 parent 16cf5d2 commit 7213f4b

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
# frozen_string_literal: true
22

33
class ChangeIssuesIdToBigint < ActiveRecord::Migration[7.0]
4-
# Disable transaction to allow running on large tables without locking for too long
5-
# You may want to run this during low-traffic periods
6-
disable_ddl_transaction!
7-
84
def up
95
# Change the id column from integer (serial) to bigint (bigserial)
106
# This is necessary because the issues table has exceeded the 32-bit integer limit
117
# Max integer: 2,147,483,647
128
# Max bigint: 9,223,372,036,854,775,807
139

14-
safety_assured do
15-
# Change the primary key column type
16-
execute "ALTER TABLE issues ALTER COLUMN id TYPE bigint"
17-
18-
# Change the sequence type to bigint as well
19-
execute "ALTER SEQUENCE issues_id_seq AS bigint"
10+
# Primary keys
11+
change_column :issues, :id, :bigint
12+
change_column :issue_assignments, :id, :bigint
2013

21-
# Also update foreign keys in issue_assignments that reference issues.id
22-
execute "ALTER TABLE issue_assignments ALTER COLUMN issue_id TYPE bigint"
23-
end
14+
# Foreign keys
15+
change_column :issue_assignments, :issue_id, :bigint
2416
end
2517

2618
def down
27-
safety_assured do
28-
# Note: This could fail if there are values > 2,147,483,647
29-
execute "ALTER TABLE issue_assignments ALTER COLUMN issue_id TYPE integer"
30-
execute "ALTER SEQUENCE issues_id_seq AS integer"
31-
execute "ALTER TABLE issues ALTER COLUMN id TYPE integer"
32-
end
19+
# Note: This could fail if there are values > 2,147,483,647
20+
change_column :issue_assignments, :issue_id, :integer
21+
change_column :issue_assignments, :id, :integer
22+
change_column :issues, :id, :integer
3323
end
3424
end

0 commit comments

Comments
 (0)