From 39b686f865854c977a8ac1384518a4475bbb4d9c Mon Sep 17 00:00:00 2001 From: apsr23 <apsr23@inf.ufpr.br> Date: Tue, 18 Mar 2025 12:09:36 -0300 Subject: [PATCH] Issue #8 ADD purchase/bodyparts table --- src/db/schema.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/db/schema.ts b/src/db/schema.ts index e601a58..b33df05 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -1,6 +1,6 @@ -import { serial, varchar, timestamp, numeric, pgTable } from "drizzle-orm/pg-core"; +import { serial, varchar, timestamp, numeric, pgEnum, integer, pgTable } from "drizzle-orm/pg-core"; -export const implants = pgTable('implants', { +export const implantsTable = pgTable('implants', { id: serial('id').primaryKey().unique().notNull(), name: varchar('nome', {length: 255}).notNull(), created_at: timestamp('created_at').notNull().defaultNow(), @@ -9,3 +9,23 @@ export const implants = pgTable('implants', { bodyPart: varchar('bodyPart', {length: 255}).notNull(), updated_at: timestamp('updated_at').notNull().defaultNow(), }); + +export const bodyPartsEnum = pgEnum('bodyPartsEnum', [ + 'FrontalCortex', + 'OperatingSystem', + 'Arms', + 'Skeleton', + 'NervousSystem', + 'IntegumentarySystem', + 'Face', + 'Hands', + 'CirculatorySystem', + 'Legs', +]); + +export const purchasesTable = pgTable('pursaches', { + id: serial('id').primaryKey().unique().notNull(), + user_id: integer('user_id').notNull().references(() => usersTable.id, { onDelete: "cascade" }), + implant_id: integer('user_id').notNull().references(() => implantsTable.id, { onDelete: "cascade" }), + created_at: timestamp('created_at').notNull().defaultNow(), +}) \ No newline at end of file -- GitLab