diff --git a/drizzle.config.ts b/drizzle.config.ts index 1c6dea1..886638f 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -1,4 +1,7 @@ import { defineConfig } from "drizzle-kit"; +import dotenv from "dotenv"; + +dotenv.config(); export default { schema: "./src/db/schema.ts", diff --git a/drizzle/0000_abandoned_titania.sql b/drizzle/0000_abandoned_titania.sql new file mode 100644 index 0000000..ec72669 --- /dev/null +++ b/drizzle/0000_abandoned_titania.sql @@ -0,0 +1,7 @@ +CREATE TABLE "users" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "username" varchar(50) NOT NULL, + "password_hash" varchar(255) NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "users_username_unique" UNIQUE("username") +); diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..041a853 --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,66 @@ +{ + "id": "1fc34e1e-d311-443f-bd56-87246c2025ea", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "username": { + "name": "username", + "type": "varchar(50)", + "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_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..143050b --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1777286818794, + "tag": "0000_abandoned_titania", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/src/db/schema.ts b/src/db/schema.ts new file mode 100644 index 0000000..f1809f3 --- /dev/null +++ b/src/db/schema.ts @@ -0,0 +1,10 @@ +import { pgTable, uuid, varchar, timestamp } from "drizzle-orm/pg-core"; + +export const users = pgTable("users", { + id: uuid("id").primaryKey().defaultRandom(), + username: varchar("username", { length: 50 }).notNull().unique(), + passwordHash: varchar("password_hash", { length: 255 }).notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: "date" }) + .defaultNow() + .notNull(), +});