diff --git a/packages/db/migrations/0000_brainy_lila_cheney.sql b/packages/db/migrations/0000_steady_rictor.sql similarity index 75% rename from packages/db/migrations/0000_brainy_lila_cheney.sql rename to packages/db/migrations/0000_steady_rictor.sql index f8455e8..733ee3d 100644 --- a/packages/db/migrations/0000_brainy_lila_cheney.sql +++ b/packages/db/migrations/0000_steady_rictor.sql @@ -10,12 +10,12 @@ CREATE TABLE IF NOT EXISTS "wc_profile" ( ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "wc_report" ( - "id" serial PRIMARY KEY NOT NULL, + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "title" varchar(256) NOT NULL, "content" text NOT NULL, "profile_id" uuid NOT NULL, - "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone ); --> statement-breakpoint DO $$ BEGIN @@ -25,7 +25,7 @@ EXCEPTION END $$; --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "wc_report" ADD CONSTRAINT "wc_report_profile_id_wc_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "wc_profile"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "wc_report" ADD CONSTRAINT "wc_report_profile_id_wc_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "public"."wc_profile"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; diff --git a/packages/db/migrations/meta/0000_snapshot.json b/packages/db/migrations/meta/0000_snapshot.json index 8cdc126..ced3e73 100644 --- a/packages/db/migrations/meta/0000_snapshot.json +++ b/packages/db/migrations/meta/0000_snapshot.json @@ -1,4 +1,6 @@ { + "id": "4ef33f95-48ee-48b7-91fc-e59d7efae202", + "prevId": "00000000-0000-0000-0000-000000000000", "version": "6", "dialect": "postgresql", "tables": { @@ -52,16 +54,16 @@ "wc_profile_id_users_id_fk": { "name": "wc_profile_id_users_id_fk", "tableFrom": "wc_profile", + "tableTo": "users", + "schemaTo": "auth", "columnsFrom": [ "id" ], - "tableTo": "users", - "schemaTo": "auth", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "cascade" + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -73,9 +75,10 @@ "columns": { "id": { "name": "id", - "type": "serial", + "type": "uuid", "primaryKey": true, - "notNull": true + "notNull": true, + "default": "gen_random_uuid()" }, "title": { "name": "title", @@ -100,14 +103,13 @@ "type": "timestamp", "primaryKey": false, "notNull": true, - "default": "CURRENT_TIMESTAMP" + "default": "now()" }, "updated_at": { "name": "updated_at", - "type": "timestamp", + "type": "timestamp with time zone", "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" + "notNull": false } }, "indexes": {}, @@ -115,15 +117,15 @@ "wc_report_profile_id_wc_profile_id_fk": { "name": "wc_report_profile_id_wc_profile_id_fk", "tableFrom": "wc_report", + "tableTo": "wc_profile", "columnsFrom": [ "profile_id" ], - "tableTo": "wc_profile", "columnsTo": [ "id" ], - "onUpdate": "no action", - "onDelete": "no action" + "onDelete": "no action", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, @@ -133,10 +135,8 @@ "enums": {}, "schemas": {}, "_meta": { + "columns": {}, "schemas": {}, - "tables": {}, - "columns": {} - }, - "id": "225a9ba0-acad-4d5c-ac65-73a6d7d8af6a", - "prevId": "00000000-0000-0000-0000-000000000000" + "tables": {} + } } \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index 98245e2..18db606 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -1,13 +1,13 @@ { - "version": "5", - "dialect": "pg", + "version": "6", + "dialect": "postgresql", "entries": [ { "idx": 0, - "version": "5", - "when": 1715131176564, - "tag": "0000_brainy_lila_cheney", + "version": "6", + "when": 1715916709318, + "tag": "0000_steady_rictor", "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/packages/db/src/schema/report.ts b/packages/db/src/schema/report.ts index e04507b..7e3bfe9 100644 --- a/packages/db/src/schema/report.ts +++ b/packages/db/src/schema/report.ts @@ -17,7 +17,7 @@ export const Report = createTable("report", { createdAt: timestamp("created_at") .default(sql`now()`) .notNull(), - updatedAt: timestamp("updatedAt", { + updatedAt: timestamp("updated_at", { mode: "date", withTimezone: true, }).$onUpdateFn(() => sql`now()`),