Add unique indexes for Collection(Item) URIs (#38409)

This commit is contained in:
David Roetzel
2026-03-26 11:17:08 +01:00
committed by GitHub
parent df479d598f
commit 1fb5cb1e67
2 changed files with 13 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
class AddUniqueIndexesToCollectionsAndItems < ActiveRecord::Migration[8.1]
disable_ddl_transaction!
def change
add_index :collections, :uri, unique: true, where: 'uri IS NOT NULL', algorithm: :concurrently
add_index :collection_items, :uri, unique: true, where: 'uri IS NOT NULL', algorithm: :concurrently
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 2026_03_23_105645) do
ActiveRecord::Schema[8.1].define(version: 2026_03_25_151755) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
@@ -374,6 +374,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_03_23_105645) do
t.index ["approval_uri"], name: "index_collection_items_on_approval_uri", unique: true, where: "(approval_uri IS NOT NULL)"
t.index ["collection_id"], name: "index_collection_items_on_collection_id"
t.index ["object_uri"], name: "index_collection_items_on_object_uri", unique: true, where: "(activity_uri IS NOT NULL)"
t.index ["uri"], name: "index_collection_items_on_uri", unique: true, where: "(uri IS NOT NULL)"
end
create_table "collection_reports", force: :cascade do |t|
@@ -402,6 +403,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_03_23_105645) do
t.string "uri"
t.index ["account_id"], name: "index_collections_on_account_id"
t.index ["tag_id"], name: "index_collections_on_tag_id"
t.index ["uri"], name: "index_collections_on_uri", unique: true, where: "(uri IS NOT NULL)"
end
create_table "conversation_mutes", force: :cascade do |t|