You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
582 B

  1. class AccountIdsToTimestampIds < ActiveRecord::Migration[5.1]
  2. def up
  3. # Set up the accounts.id column to use our timestamp-based IDs.
  4. safety_assured do
  5. execute("ALTER TABLE accounts ALTER COLUMN id SET DEFAULT timestamp_id('accounts')")
  6. end
  7. # Make sure we have a sequence to use.
  8. Mastodon::Snowflake.ensure_id_sequences_exist
  9. end
  10. def down
  11. execute("LOCK accounts")
  12. execute("SELECT setval('accounts_id_seq', (SELECT MAX(id) FROM accounts))")
  13. execute("ALTER TABLE accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq')")
  14. end
  15. end