howmuch/migrations/20241017215923_create_participation_table.postgres.up.sql
2024-10-18 19:36:31 +02:00

17 lines
478 B
SQL

CREATE TABLE "participation" (
"id" serial NOT NULL,
PRIMARY KEY ("id"),
"user_id" integer NOT NULL,
"event_id" integer NOT NULL,
"invited_by_user_id" integer NULL,
"created_at" date NOT NULL,
"updated_at" date NOT NULL
);
ALTER TABLE "participation"
ADD FOREIGN KEY ("event_id") REFERENCES "event" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "participation"
ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE;