mirror of https://github.com/mastodon/mastodon
Change quote IDs to use snowflake IDs (#34551)
parent
a97647158c
commit
8f59b63176
@ -0,0 +1,19 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class QuoteIdsToTimestampIds < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
# Set up the media_attachments.id column to use our timestamp-based IDs.
|
||||||
|
safety_assured do
|
||||||
|
execute("ALTER TABLE quotes ALTER COLUMN id SET DEFAULT timestamp_id('quotes')")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Make sure we have a sequence to use.
|
||||||
|
Mastodon::Snowflake.ensure_id_sequences_exist
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
execute('LOCK quotes')
|
||||||
|
execute("SELECT setval('quotes_id_seq', (SELECT MAX(id) FROM quotes))")
|
||||||
|
execute("ALTER TABLE quotes ALTER COLUMN id SET DEFAULT nextval('quotes_id_seq')")
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue