diff --git a/db/migrate/20251216122223_change_id_sequences_to_bigint.rb b/db/migrate/20251216122223_change_id_sequences_to_bigint.rb new file mode 100644 index 00000000000..ac9ec5edd2d --- /dev/null +++ b/db/migrate/20251216122223_change_id_sequences_to_bigint.rb @@ -0,0 +1,22 @@ +class ChangeIdSequencesToBigint < ActiveRecord::Migration[7.0] + # The 20170110113824_change_id_value_range migration changed logs.id, reports.id, + # and fact_values.id columns to bigint, but ActiveRecord's change_column doesn't + # update the underlying sequence type. This fixes the sequences to allow values + # beyond 2^31-1. + + def up + change_sequence :logs_id_seq, as: :bigint + change_sequence :reports_id_seq, as: :bigint + change_sequence :fact_values_id_seq, as: :bigint + end + + def down + raise ActiveRecord::IrreversibleMigration + end + + private + + def change_sequence(name, as:) + connection.execute("ALTER SEQUENCE #{connection.quote_table_name(name)} AS #{as}") + end +end