Voeg PushSubscription model toe aan prisma/schema.prisma met snake_case-conventie, relation field op User, en bijbehorende migratie (push_subscriptions tabel, FK + index op user_id). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
801 B
SQL
20 lines
801 B
SQL
-- PushSubscription model for Web Push notifications (PBI-55)
|
|
|
|
CREATE TABLE "push_subscriptions" (
|
|
"id" TEXT NOT NULL,
|
|
"user_id" TEXT NOT NULL,
|
|
"endpoint" TEXT NOT NULL,
|
|
"p256dh" TEXT NOT NULL,
|
|
"auth" TEXT NOT NULL,
|
|
"user_agent" TEXT,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"last_used_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "push_subscriptions_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
CREATE UNIQUE INDEX "push_subscriptions_endpoint_key" ON "push_subscriptions"("endpoint");
|
|
|
|
CREATE INDEX "push_subscriptions_user_id_idx" ON "push_subscriptions"("user_id");
|
|
|
|
ALTER TABLE "push_subscriptions" ADD CONSTRAINT "push_subscriptions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|