feat(submodules): to help with submodules of course
This commit is contained in:
45
database/schema/subModules.ts
Normal file
45
database/schema/subModules.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import {
|
||||||
|
text,
|
||||||
|
pgTable,
|
||||||
|
timestamp,
|
||||||
|
boolean,
|
||||||
|
uuid,
|
||||||
|
uniqueIndex,
|
||||||
|
jsonb,
|
||||||
|
} from "drizzle-orm/pg-core";
|
||||||
|
import { createSelectSchema } from "drizzle-zod";
|
||||||
|
import { modules } from "./modules.js";
|
||||||
|
//import {z} from "zod";
|
||||||
|
|
||||||
|
export const subModules = pgTable(
|
||||||
|
"subModules",
|
||||||
|
{
|
||||||
|
submodule_id: uuid("submodule_id").defaultRandom().primaryKey(),
|
||||||
|
moduleName: text("moduleName"),
|
||||||
|
// .notNull()
|
||||||
|
// .references(() => modules.name),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
description: text("description"),
|
||||||
|
link: text("link").notNull(),
|
||||||
|
active: boolean("active").default(false),
|
||||||
|
roles: jsonb("roles").notNull().default(["systemAdmin"]), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
|
||||||
|
subSubModule: jsonb("subSubModule").default([]),
|
||||||
|
add_User: text("add_User").default("LST_System").notNull(),
|
||||||
|
add_Date: timestamp("add_Date").defaultNow(),
|
||||||
|
upd_user: text("upd_User").default("LST_System").notNull(),
|
||||||
|
upd_date: timestamp("upd_date").defaultNow(),
|
||||||
|
}
|
||||||
|
// (table) => [
|
||||||
|
// // uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||||
|
// uniqueIndex("subModule_name").on(table.name),
|
||||||
|
// ]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Schema for inserting a user - can be used to validate API requests
|
||||||
|
// export const insertModuleSchema = createInsertSchema(modules, {
|
||||||
|
// name: z.string().min(3, {message: "Module name should be longer than 3 letters"}),
|
||||||
|
// });
|
||||||
|
// Schema for selecting a Expenses - can be used to validate API responses
|
||||||
|
export const selectModuleSchema = createSelectSchema(subModules);
|
||||||
|
|
||||||
|
export type Modules = typeof subModules;
|
||||||
Reference in New Issue
Block a user