Enable new schema for file types and machines
Removed the deprecated `firstName` and `lastName` fields and introduced `email` and `uploader` fields. Added `FilesTypesTable`, `MachinesTable`, and `FilesTypeForMachine` for managing file types and machine associations. Updated the `fileType` field to reference `FilesTypesTable`.
This commit is contained in:
parent
b4c4151550
commit
be121ef7ca
@ -6,7 +6,7 @@ export const UsersTable = pgTable("users", {
|
||||
// Unique identifier on a technical aspect.
|
||||
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
||||
|
||||
firstName: p
|
||||
/*firstName: p
|
||||
.varchar("first_name", {
|
||||
length: 24,
|
||||
})
|
||||
@ -16,6 +16,12 @@ export const UsersTable = pgTable("users", {
|
||||
.varchar("last_name", {
|
||||
length: 24,
|
||||
})
|
||||
.notNull(),**/
|
||||
|
||||
email: p
|
||||
.varchar("email", {
|
||||
length: 64,
|
||||
})
|
||||
.notNull(),
|
||||
|
||||
//hash (Argonid2 hash)
|
||||
@ -55,14 +61,20 @@ export const FilesTable = pgTable("files", {
|
||||
})
|
||||
.notNull(),
|
||||
|
||||
uploader: p
|
||||
.varchar("uploader", {
|
||||
length: 64,
|
||||
})
|
||||
.default("anonyme")
|
||||
.notNull(),
|
||||
|
||||
fileSize: p.integer("file_size").notNull(),
|
||||
|
||||
//TODO Replace by file type reference
|
||||
fileType: p
|
||||
.varchar("file_type", {
|
||||
length: 50,
|
||||
})
|
||||
.notNull(),
|
||||
.uuid("file_type")
|
||||
.notNull()
|
||||
.references(() => FilesTypesTable.id),
|
||||
|
||||
isRestricted: p.boolean("is_restricted").default(false).notNull(),
|
||||
|
||||
@ -80,6 +92,50 @@ export const FilesTable = pgTable("files", {
|
||||
.notNull(),
|
||||
});
|
||||
|
||||
//TODO Many/Many Files -> Categories
|
||||
|
||||
//TODO Files types
|
||||
export const FilesTypesTable = pgTable("f_types", {
|
||||
//uuid
|
||||
id: p.uuid("id").unique().primaryKey().defaultRandom().notNull(),
|
||||
|
||||
typeName: p
|
||||
.varchar("type_name", {
|
||||
length: 64,
|
||||
})
|
||||
.notNull(),
|
||||
|
||||
mime: p
|
||||
.varchar("mime_type", {
|
||||
length: 64,
|
||||
})
|
||||
.unique()
|
||||
.notNull(),
|
||||
});
|
||||
|
||||
export const MachinesTable = pgTable("machines", {
|
||||
id: p.uuid("id").unique().primaryKey().defaultRandom().notNull(),
|
||||
|
||||
machineName: p
|
||||
.varchar("machine_name", {
|
||||
length: 64,
|
||||
})
|
||||
.notNull(),
|
||||
|
||||
machineType: p
|
||||
.varchar("machine_type", {
|
||||
length: 64,
|
||||
})
|
||||
.notNull(),
|
||||
|
||||
//supported files format
|
||||
});
|
||||
|
||||
export const FilesTypeForMachine = pgTable("f_type_for_machines", {
|
||||
machineId: p
|
||||
.uuid("machine_id")
|
||||
.notNull()
|
||||
.references(() => MachinesTable.id),
|
||||
fileTypeId: p
|
||||
.uuid("file_type_id")
|
||||
.notNull()
|
||||
.references(() => FilesTypesTable.id),
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user