diff --git a/migrations/20241017215433_create_event_table.postgres.down.sql b/migrations/20241017215433_create_event_table.postgres.down.sql new file mode 100644 index 0000000..3294845 --- /dev/null +++ b/migrations/20241017215433_create_event_table.postgres.down.sql @@ -0,0 +1 @@ +DROP TABLE "event" diff --git a/migrations/20241017215433_create_event_table.postgres.up.sql b/migrations/20241017215433_create_event_table.postgres.up.sql new file mode 100644 index 0000000..d1e98a6 --- /dev/null +++ b/migrations/20241017215433_create_event_table.postgres.up.sql @@ -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 +); diff --git a/migrations/20241017215923_create_participation_table.postgres.down.sql b/migrations/20241017215923_create_participation_table.postgres.down.sql new file mode 100644 index 0000000..9a29d40 --- /dev/null +++ b/migrations/20241017215923_create_participation_table.postgres.down.sql @@ -0,0 +1 @@ +DROP TABLE participation; diff --git a/migrations/20241017215923_create_participation_table.postgres.up.sql b/migrations/20241017215923_create_participation_table.postgres.up.sql new file mode 100644 index 0000000..dbc146d --- /dev/null +++ b/migrations/20241017215923_create_participation_table.postgres.up.sql @@ -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; + diff --git a/migrations/20241017220309_event_add_total_amount.postgres.down.sql b/migrations/20241017220309_event_add_total_amount.postgres.down.sql new file mode 100644 index 0000000..e69de29 diff --git a/migrations/20241017220309_event_add_total_amount.postgres.up.sql b/migrations/20241017220309_event_add_total_amount.postgres.up.sql new file mode 100644 index 0000000..1dfe158 --- /dev/null +++ b/migrations/20241017220309_event_add_total_amount.postgres.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE "event" +ADD "total_amount" integer NULL;