diff --git a/drizzle/0001_brown_lucky_pierre.sql b/drizzle/0001_brown_lucky_pierre.sql new file mode 100644 index 0000000..0bc81c9 --- /dev/null +++ b/drizzle/0001_brown_lucky_pierre.sql @@ -0,0 +1,9 @@ +CREATE TYPE "public"."asset_type_enum" AS ENUM('STOCK', 'CRYPTO', 'CASH');--> statement-breakpoint +CREATE TABLE "assets" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "symbol" varchar(20) NOT NULL, + "type" "asset_type_enum" NOT NULL, + "base_currency" varchar(10) NOT NULL, + "created_at" timestamp with time zone DEFAULT now(), + CONSTRAINT "assets_symbol_unique" UNIQUE("symbol") +); diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..b0ff21e --- /dev/null +++ b/drizzle/meta/0001_snapshot.json @@ -0,0 +1,130 @@ +{ + "id": "efb1ef58-df53-4e36-b691-ee9811c3ab36", + "prevId": "1fc34e1e-d311-443f-bd56-87246c2025ea", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "symbol": { + "name": "symbol", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "asset_type_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "base_currency": { + "name": "base_currency", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "assets_symbol_unique": { + "name": "assets_symbol_unique", + "nullsNotDistinct": false, + "columns": [ + "symbol" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "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": { + "public.asset_type_enum": { + "name": "asset_type_enum", + "schema": "public", + "values": [ + "STOCK", + "CRYPTO", + "CASH" + ] + } + }, + "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 index 143050b..fc2e9dd 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1777286818794, "tag": "0000_abandoned_titania", "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1777288158234, + "tag": "0001_brown_lucky_pierre", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/db/schema.ts b/src/db/schema.ts index f1809f3..f028a75 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -1,4 +1,4 @@ -import { pgTable, uuid, varchar, timestamp } from "drizzle-orm/pg-core"; +import { pgTable, uuid, varchar, timestamp, pgEnum } from "drizzle-orm/pg-core"; export const users = pgTable("users", { id: uuid("id").primaryKey().defaultRandom(), @@ -8,3 +8,18 @@ export const users = pgTable("users", { .defaultNow() .notNull(), }); + +export const assetTypeEnum = pgEnum("asset_type_enum", [ + "STOCK", + "CRYPTO", + "CASH", +]); + +export const assets = pgTable("assets", { + id: uuid("id").primaryKey().defaultRandom(), + symbol: varchar("symbol", { length: 20 }).notNull().unique(), + type: assetTypeEnum("type").notNull(), + baseCurrency: varchar("base_currency", { length: 10 }).notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: "date" }) + .defaultNow(), +});