From 93b5e289f366397458127a798162f332b1b905ad Mon Sep 17 00:00:00 2001 From: Matiss Jurevics Date: Sun, 7 Dec 2025 15:22:00 +0000 Subject: [PATCH] feat: add events table to schema and update SQL migration script --- Backend/db/schema.ts | 7 ++ Backend/drizzle/0000_certain_jocasta.sql | 8 -- Backend/drizzle/0001_regular_ulik.sql | 1 + .../drizzle/0002_hesitant_molecule_man.sql | 7 ++ Backend/drizzle/meta/0001_snapshot.json | 72 +++++++++++ Backend/drizzle/meta/0002_snapshot.json | 119 ++++++++++++++++++ Backend/drizzle/meta/_journal.json | 14 +++ 7 files changed, 220 insertions(+), 8 deletions(-) create mode 100644 Backend/drizzle/0001_regular_ulik.sql create mode 100644 Backend/drizzle/0002_hesitant_molecule_man.sql create mode 100644 Backend/drizzle/meta/0001_snapshot.json create mode 100644 Backend/drizzle/meta/0002_snapshot.json diff --git a/Backend/db/schema.ts b/Backend/db/schema.ts index d3f1832..c93bce7 100644 --- a/Backend/db/schema.ts +++ b/Backend/db/schema.ts @@ -7,3 +7,10 @@ export const users = pgTable('users', { passwordHash: varchar('password_hash', { length: 255 }).notNull(), createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), }); + +export const events = pgTable('events', { + id: uuid('id').defaultRandom().primaryKey(), + title: varchar('title', { length: 255 }).notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + videoUrl: varchar('video_url', { length: 255 }).notNull().unique(), +}); \ No newline at end of file diff --git a/Backend/drizzle/0000_certain_jocasta.sql b/Backend/drizzle/0000_certain_jocasta.sql index afd4894..30b1a0e 100644 --- a/Backend/drizzle/0000_certain_jocasta.sql +++ b/Backend/drizzle/0000_certain_jocasta.sql @@ -7,12 +7,4 @@ CREATE TABLE "users" ( CONSTRAINT "users_email_unique" UNIQUE("email") ); -CREATE TABLE "events" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "title" varchar(255) NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "video_url" varchar(255) NOT NULL, - CONSTRAINT "events_url_unique" UNIQUE("url") -) - diff --git a/Backend/drizzle/0001_regular_ulik.sql b/Backend/drizzle/0001_regular_ulik.sql new file mode 100644 index 0000000..659a111 --- /dev/null +++ b/Backend/drizzle/0001_regular_ulik.sql @@ -0,0 +1 @@ +ALTER TABLE "users" ADD COLUMN "password_hash" varchar(255) NOT NULL; \ No newline at end of file diff --git a/Backend/drizzle/0002_hesitant_molecule_man.sql b/Backend/drizzle/0002_hesitant_molecule_man.sql new file mode 100644 index 0000000..61dccae --- /dev/null +++ b/Backend/drizzle/0002_hesitant_molecule_man.sql @@ -0,0 +1,7 @@ +CREATE TABLE "events" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "title" varchar(255) NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "video_url" varchar(255) NOT NULL, + CONSTRAINT "events_video_url_unique" UNIQUE("video_url") +); diff --git a/Backend/drizzle/meta/0001_snapshot.json b/Backend/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..6a496bd --- /dev/null +++ b/Backend/drizzle/meta/0001_snapshot.json @@ -0,0 +1,72 @@ +{ + "id": "9f375a0f-ac87-4ce2-817e-7ef39284c564", + "prevId": "0af28e11-17c5-4f97-9e07-ed56b931c6f6", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/Backend/drizzle/meta/0002_snapshot.json b/Backend/drizzle/meta/0002_snapshot.json new file mode 100644 index 0000000..68b5c8a --- /dev/null +++ b/Backend/drizzle/meta/0002_snapshot.json @@ -0,0 +1,119 @@ +{ + "id": "1edd6921-94b0-4232-805a-d0f96da49b67", + "prevId": "9f375a0f-ac87-4ce2-817e-7ef39284c564", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "video_url": { + "name": "video_url", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "events_video_url_unique": { + "name": "events_video_url_unique", + "nullsNotDistinct": false, + "columns": [ + "video_url" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/Backend/drizzle/meta/_journal.json b/Backend/drizzle/meta/_journal.json index 970ad38..7e4ecab 100644 --- a/Backend/drizzle/meta/_journal.json +++ b/Backend/drizzle/meta/_journal.json @@ -8,6 +8,20 @@ "when": 1770404105580, "tag": "0000_certain_jocasta", "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1770405234430, + "tag": "0001_regular_ulik", + "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1770406019154, + "tag": "0002_hesitant_molecule_man", + "breakpoints": true } ] } \ No newline at end of file