Add spaces concept (#1776)

This commit is contained in:
Luke Vella 2025-06-15 11:48:51 +02:00 committed by GitHub
parent 92a72dde60
commit 04fcc0350f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 389 additions and 93 deletions

View file

@ -0,0 +1,34 @@
/*
Warnings:
- A unique constraint covering the columns `[space_id]` on the table `subscriptions` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "polls" ADD COLUMN "space_id" TEXT;
-- AlterTable
ALTER TABLE "subscriptions" ADD COLUMN "space_id" TEXT;
-- CreateTable
CREATE TABLE "spaces" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"owner_id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "spaces_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "subscriptions_space_id_key" ON "subscriptions"("space_id");
-- AddForeignKey
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_space_id_fkey" FOREIGN KEY ("space_id") REFERENCES "spaces"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "polls" ADD CONSTRAINT "polls_space_id_fkey" FOREIGN KEY ("space_id") REFERENCES "spaces"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "spaces" ADD CONSTRAINT "spaces_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;