20200521180606_encrypted_message_ids_to_timestamp_ids.rb 530 B

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