From 14991d780138a1a6b0cbe76eb41f8243cf787f82 Mon Sep 17 00:00:00 2001 From: liangxu Date: Wed, 6 May 2026 18:25:35 +0800 Subject: [PATCH] fix(server): scope platform accounts to desktop clients --- ...20260402140000_create_media_publisher_tables.up.sql | 3 --- ...0010_add_desktop_fields_to_platform_accounts.up.sql | 2 -- ..._scope_platform_accounts_to_desktop_client.down.sql | 6 ++++++ ...00_scope_platform_accounts_to_desktop_client.up.sql | 10 ++++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.down.sql create mode 100644 server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.up.sql diff --git a/server/migrations/20260402140000_create_media_publisher_tables.up.sql b/server/migrations/20260402140000_create_media_publisher_tables.up.sql index 78c8a9a..1e2db0e 100644 --- a/server/migrations/20260402140000_create_media_publisher_tables.up.sql +++ b/server/migrations/20260402140000_create_media_publisher_tables.up.sql @@ -48,9 +48,6 @@ CREATE TABLE platform_accounts ( deleted_at TIMESTAMPTZ ); -CREATE UNIQUE INDEX uk_platform_accounts_identity_active - ON platform_accounts(tenant_id, platform_id, platform_uid) - WHERE deleted_at IS NULL; CREATE INDEX idx_platform_accounts_tenant_platform ON platform_accounts(tenant_id, platform_id, status, created_at DESC); CREATE TABLE publish_batches ( diff --git a/server/migrations/20260421100010_add_desktop_fields_to_platform_accounts.up.sql b/server/migrations/20260421100010_add_desktop_fields_to_platform_accounts.up.sql index 1ddc512..f5f060f 100644 --- a/server/migrations/20260421100010_add_desktop_fields_to_platform_accounts.up.sql +++ b/server/migrations/20260421100010_add_desktop_fields_to_platform_accounts.up.sql @@ -47,8 +47,6 @@ ALTER TABLE platform_accounts ALTER COLUMN health SET NOT NULL, ALTER COLUMN sync_version SET NOT NULL; -DROP INDEX IF EXISTS uk_platform_accounts_identity_active; - CREATE UNIQUE INDEX IF NOT EXISTS uniq_platform_accounts_desktop_id ON platform_accounts (desktop_id); diff --git a/server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.down.sql b/server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.down.sql new file mode 100644 index 0000000..16c0005 --- /dev/null +++ b/server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.down.sql @@ -0,0 +1,6 @@ +DROP INDEX IF EXISTS idx_platform_accounts_client_id; +DROP INDEX IF EXISTS uniq_platform_accounts_workspace_identity_active; + +CREATE UNIQUE INDEX IF NOT EXISTS uk_platform_accounts_identity_active + ON platform_accounts (tenant_id, platform_id, platform_uid) + WHERE deleted_at IS NULL; diff --git a/server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.up.sql b/server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.up.sql new file mode 100644 index 0000000..c09ff02 --- /dev/null +++ b/server/migrations/20260506120000_scope_platform_accounts_to_desktop_client.up.sql @@ -0,0 +1,10 @@ +DROP INDEX IF EXISTS uk_platform_accounts_identity_active; +DROP INDEX IF EXISTS uniq_platform_accounts_workspace_identity_active; + +CREATE UNIQUE INDEX IF NOT EXISTS uniq_platform_accounts_workspace_identity_active + ON platform_accounts (workspace_id, client_id, platform_id, platform_uid) + WHERE deleted_at IS NULL; + +CREATE INDEX IF NOT EXISTS idx_platform_accounts_client_id + ON platform_accounts (client_id) + WHERE deleted_at IS NULL;