From 8b5a4640c1956ef1311661d79978a507bcdc347b Mon Sep 17 00:00:00 2001 From: Mathis Date: Thu, 17 Oct 2024 12:11:58 +0200 Subject: [PATCH] Introduce type exports in database schema Improved the readability and usability of the database schema by introducing type exports for each table. The exported types (IFileTable, IFileGroupTable, IFilesTypesTable, IMachinesTable, IFilesForMachinesTable, IFilesTypeForMachine) will allow the schemas to be more easily referenced and utilized in other parts of the codebase. --- apps/backend/src/app/db/schema.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/backend/src/app/db/schema.ts b/apps/backend/src/app/db/schema.ts index 48e2009..3d9c75e 100644 --- a/apps/backend/src/app/db/schema.ts +++ b/apps/backend/src/app/db/schema.ts @@ -103,6 +103,7 @@ export const FilesTable = pgTable("files", { }) .notNull(), }); +export type IFileTable = typeof FilesTable.$inferSelect export const FilesGroupTable = pgTable("f_groups", { uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(), @@ -114,6 +115,8 @@ export const FilesGroupTable = pgTable("f_groups", { .unique() .notNull(), }); +export type IFileGroupTable = typeof FilesGroupTable.$inferSelect + //TODO Files types export const FilesTypesTable = pgTable("f_types", { @@ -134,6 +137,7 @@ export const FilesTypesTable = pgTable("f_types", { .unique() .notNull(), }); +export type IFilesTypesTable = typeof FilesTypesTable.$inferSelect export const MachinesTable = pgTable("machines", { id: p.uuid("id").unique().primaryKey().defaultRandom().notNull(), @@ -152,6 +156,7 @@ export const MachinesTable = pgTable("machines", { //supported files format }); +export type IMachinesTable = typeof MachinesTable.$inferSelect //TODO Many to Many table betwen File en Machine export const FilesForMachinesTable = pgTable("files_for_machines", { @@ -167,6 +172,7 @@ export const FilesForMachinesTable = pgTable("files_for_machines", { .notNull() .references(() => MachinesTable.id), }); +export type IFilesForMachinesTable = typeof FilesForMachinesTable.$inferSelect export const FilesTypeForMachine = pgTable("f_type_for_machines", { id: p.uuid("id").unique().primaryKey().defaultRandom().notNull(), @@ -180,3 +186,4 @@ export const FilesTypeForMachine = pgTable("f_type_for_machines", { .notNull() .references(() => FilesTypesTable.id), }); +export type IFilesTypeForMachine = typeof FilesTypeForMachine.$inferSelect \ No newline at end of file