20200521180606_encrypted_message_ids_to_timestamp_ids.rb 499 B

12345678910111213
  1. class EncryptedMessageIdsToTimestampIds < ActiveRecord::Migration[5.2]
  2. def up
  3. safety_assured do
  4. execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT timestamp_id('encrypted_messages')")
  5. end
  6. end
  7. def down
  8. execute("LOCK encrypted_messages")
  9. execute("SELECT setval('encrypted_messages_id_seq', (SELECT MAX(id) FROM encrypted_messages))")
  10. execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT nextval('encrypted_messages_id_seq')")
  11. end
  12. end