Unveränderter Stand von certvia/dev (a48c5fb) plus Craftvia-Spezifikation und Brandbook unter docs/craftvia/. ISMS-Module werden im Folgecommit entfernt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
36 lines
1.7 KiB
SQL
36 lines
1.7 KiB
SQL
-- ============================================================================
|
|
-- WS4b (Option C) — WebAuthn/Passkeys von der Mitgliedschaft auf die GLOBALE Identity
|
|
-- ============================================================================
|
|
-- Passkeys sind identitäts-, nicht mandantengebunden. Die Tabelle verliert daher
|
|
-- tenant_id + RLS und verweist künftig auf `identities`. `webauthn_credentials` ist
|
|
-- damit ein GLOBALES Modell (nicht mehr in TENANT_MODELS).
|
|
--
|
|
-- Reihenfolge: erst RLS/Policy abbauen (die Policy referenziert tenant_id), dann die
|
|
-- Spalten umbauen. identity_id ist NOT NULL — die Migration läuft auf einer leeren
|
|
-- Tabelle (im Seed werden keine Passkeys angelegt; Bestand = Testdaten).
|
|
-- ============================================================================
|
|
|
|
-- RLS/Policy entfernen (war über webauthn_credentials-Migration + rls_enforce gesetzt).
|
|
ALTER TABLE "webauthn_credentials" DISABLE ROW LEVEL SECURITY;
|
|
DROP POLICY IF EXISTS tenant_isolation ON "webauthn_credentials";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "webauthn_credentials" DROP CONSTRAINT "webauthn_credentials_user_id_fkey";
|
|
|
|
-- DropIndex
|
|
DROP INDEX "webauthn_credentials_tenant_id_idx";
|
|
|
|
-- DropIndex
|
|
DROP INDEX "webauthn_credentials_user_id_idx";
|
|
|
|
-- AlterTable: tenant_id/user_id → identity_id
|
|
ALTER TABLE "webauthn_credentials" DROP COLUMN "tenant_id",
|
|
DROP COLUMN "user_id",
|
|
ADD COLUMN "identity_id" TEXT NOT NULL;
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "webauthn_credentials_identity_id_idx" ON "webauthn_credentials"("identity_id");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "webauthn_credentials" ADD CONSTRAINT "webauthn_credentials_identity_id_fkey" FOREIGN KEY ("identity_id") REFERENCES "identities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|