From f2a45ce2718b53866e14b3bc9766b199fe7f3198 Mon Sep 17 00:00:00 2001 From: Mathis Date: Mon, 2 Sep 2024 15:50:48 +0200 Subject: [PATCH] Add groupId column and FilesGroupTable schema Added the `groupId` column to the existing table to link with the new `FilesGroupTable`. The `FilesGroupTable` includes a unique identifier and a unique group name to manage file groups effectively. --- apps/backend/src/app/db/schema.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/backend/src/app/db/schema.ts b/apps/backend/src/app/db/schema.ts index 8adc553..a8135ce 100644 --- a/apps/backend/src/app/db/schema.ts +++ b/apps/backend/src/app/db/schema.ts @@ -68,6 +68,10 @@ export const FilesTable = pgTable("files", { .default("anonyme") .notNull(), + groupId: p + .uuid("group_id") + .references(()=> FilesGroupTable.uuid), + fileSize: p.integer("file_size").notNull(), //TODO Replace by file type reference @@ -92,6 +96,18 @@ export const FilesTable = pgTable("files", { .notNull(), }); +export const FilesGroupTable = pgTable("f_groups", { + // Unique identifier on a technical aspect. + uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(), + + groupName: p + .varchar("group_name", { + length: 64, + }) + .unique() + .notNull(), +}) + //TODO Files types export const FilesTypesTable = pgTable("f_types", { //uuid