ALTER TABLE "workspaces"
  ADD CONSTRAINT "workspaces_tenant_id_id_unique" UNIQUE ("tenant_id", "id");
--> statement-breakpoint
ALTER TABLE "content_items"
  ADD CONSTRAINT "content_items_tenant_workspace_fk"
  FOREIGN KEY ("tenant_id", "workspace_id")
  REFERENCES "public"."workspaces"("tenant_id", "id")
  ON DELETE restrict ON UPDATE no action;
--> statement-breakpoint
ALTER TABLE "tenants" ENABLE ROW LEVEL SECURITY;
--> statement-breakpoint
CREATE POLICY "tenants_self_isolation" ON "tenants"
  USING (
    "id" = nullif(current_setting('app.current_tenant_id', true), '')::uuid
  )
  WITH CHECK (
    "id" = nullif(current_setting('app.current_tenant_id', true), '')::uuid
  );
