Use snowflake ids for collections and their items (#37514)
This commit is contained in:
parent
0d9fcb59a4
commit
be00db4fa3
@ -0,0 +1,25 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class UseSnowflakeIdsForCollections < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
safety_assured do
|
||||||
|
execute(<<~SQL.squish)
|
||||||
|
ALTER TABLE collections ALTER COLUMN id SET DEFAULT timestamp_id('collections');
|
||||||
|
ALTER TABLE collection_items ALTER COLUMN id SET DEFAULT timestamp_id('collection_items');
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
Mastodon::Snowflake.ensure_id_sequences_exist
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
execute(<<~SQL.squish)
|
||||||
|
LOCK collections;
|
||||||
|
SELECT setval('collections_id_seq', (SELECT MAX(id) FROM collections));
|
||||||
|
ALTER TABLE collections ALTER COLUMN id SET DEFAULT nextval('collections_id_seq');
|
||||||
|
LOCK collection_items;
|
||||||
|
SELECT setval('collection_items_id_seq', (SELECT MAX(id) FROM collection_items));
|
||||||
|
ALTER TABLE collection_items ALTER COLUMN id SET DEFAULT nextval('collection_items_id_seq');
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_12_17_091936) do
|
ActiveRecord::Schema[8.0].define(version: 2026_01_15_153219) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_catalog.plpgsql"
|
enable_extension "pg_catalog.plpgsql"
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_17_091936) do
|
|||||||
t.index ["reference_account_id"], name: "index_canonical_email_blocks_on_reference_account_id"
|
t.index ["reference_account_id"], name: "index_canonical_email_blocks_on_reference_account_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "collection_items", force: :cascade do |t|
|
create_table "collection_items", id: :bigint, default: -> { "timestamp_id('collection_items'::text)" }, force: :cascade do |t|
|
||||||
t.bigint "collection_id", null: false
|
t.bigint "collection_id", null: false
|
||||||
t.bigint "account_id"
|
t.bigint "account_id"
|
||||||
t.integer "position", default: 1, null: false
|
t.integer "position", default: 1, null: false
|
||||||
@ -369,7 +369,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_17_091936) do
|
|||||||
t.index ["object_uri"], name: "index_collection_items_on_object_uri", unique: true, where: "(activity_uri IS NOT NULL)"
|
t.index ["object_uri"], name: "index_collection_items_on_object_uri", unique: true, where: "(activity_uri IS NOT NULL)"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "collections", force: :cascade do |t|
|
create_table "collections", id: :bigint, default: -> { "timestamp_id('collections'::text)" }, force: :cascade do |t|
|
||||||
t.bigint "account_id", null: false
|
t.bigint "account_id", null: false
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.text "description", null: false
|
t.text "description", null: false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user