Ajoute la définition des tables d'utilisateurs et de fichiers
Crée les tables `UsersTable` et `FilesTable` dans le schéma de la base de données, incluant les schémas de sélection et d'insertion pour les utilisateurs. Les tables comportent des colonnes pour gérer les informations de l'utilisateur et des fichiers, ainsi que les métadonnées associées.
This commit is contained in:
parent
0bb8185247
commit
fef0229cba
91
apps/backend/src/app/db/schema.ts
Normal file
91
apps/backend/src/app/db/schema.ts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import { pgTable } from "drizzle-orm/pg-core";
|
||||||
|
import * as p from "drizzle-orm/pg-core";
|
||||||
|
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||||
|
|
||||||
|
export const UsersTable = pgTable("users", {
|
||||||
|
// Unique identifier on a technical aspect.
|
||||||
|
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
||||||
|
|
||||||
|
firstName: p
|
||||||
|
.varchar("first_name", {
|
||||||
|
length: 24,
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
lastName: p
|
||||||
|
.varchar("last_name", {
|
||||||
|
length: 24,
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
//hash (Argonid2 hash)
|
||||||
|
hash: p
|
||||||
|
.varchar("hash", {
|
||||||
|
length: 97,
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
//METADATA
|
||||||
|
iat: p
|
||||||
|
.timestamp("issued_at", {
|
||||||
|
withTimezone: true,
|
||||||
|
})
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
gdprAcceptance: p
|
||||||
|
.timestamp("ack_gdpr", {
|
||||||
|
withTimezone: true,
|
||||||
|
})
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
isAdmin: p.boolean("is_admin").default(false).notNull(),
|
||||||
|
});
|
||||||
|
export const UsersTableSelectSchema = createSelectSchema(UsersTable);
|
||||||
|
export const UsersTableInsertSchema = createInsertSchema(UsersTable);
|
||||||
|
|
||||||
|
export const FilesTable = pgTable("files", {
|
||||||
|
// Unique identifier on a technical aspect.
|
||||||
|
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
||||||
|
|
||||||
|
fileName: p
|
||||||
|
.varchar("file_name", {
|
||||||
|
length: 128,
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
fileSize: p
|
||||||
|
.integer("file_size")
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
//TODO Replace by file type reference
|
||||||
|
fileType: p
|
||||||
|
.varchar("file_type", {
|
||||||
|
length: 50,
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
isRestricted: p
|
||||||
|
.boolean("is_restricted")
|
||||||
|
.default(false)
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
uploadedAt: p
|
||||||
|
.timestamp("uploaded_at", {
|
||||||
|
withTimezone: true,
|
||||||
|
})
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
|
uploadedBy: p
|
||||||
|
.varchar("uploaded_by", {
|
||||||
|
length: 64,
|
||||||
|
})
|
||||||
|
.notNull(),
|
||||||
|
})
|
||||||
|
|
||||||
|
//TODO Many/Many Files -> Categories
|
||||||
|
|
||||||
|
//TODO Files types
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user