db: add migrations

This commit is contained in:
Muyao CHEN 2024-10-18 19:36:31 +02:00
parent 86832cf1f9
commit 39eaae46d8
6 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1 @@
DROP TABLE "event"

View File

@ -0,0 +1,10 @@
CREATE TABLE "event" (
"id" serial NOT NULL,
PRIMARY KEY ("id"),
"name" character varying(255) NOT NULL,
"description" character varying(10000) NULL,
"default_currency" character varying(255) NOT NULL,
"owner_id" integer NOT NULL,
"created_at" date NOT NULL,
"updated_at" date NOT NULL
);

View File

@ -0,0 +1 @@
DROP TABLE participation;

View File

@ -0,0 +1,16 @@
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;

View File

@ -0,0 +1,2 @@
ALTER TABLE "event"
ADD "total_amount" integer NULL;