fix(server): scope platform accounts to desktop clients
Frontend CI / Frontend (push) Successful in 2m52s
Backend CI / Backend (push) Successful in 14m14s

This commit is contained in:
2026-05-06 18:25:35 +08:00
parent 47681ab1f5
commit 14991d7801
4 changed files with 16 additions and 5 deletions
@@ -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 (
@@ -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);
@@ -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;
@@ -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;