feat(database): settings added in
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {text, pgTable, timestamp, boolean, uuid, uniqueIndex} from "drizzle-orm/pg-core";
|
||||
import {text, pgTable, timestamp, boolean, uuid, uniqueIndex, jsonb} from "drizzle-orm/pg-core";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
//import {z} from "zod";
|
||||
|
||||
@@ -8,7 +8,8 @@ export const modules = pgTable(
|
||||
module_id: uuid("module_id").defaultRandom().primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
active: boolean("active").default(false),
|
||||
roles: text("roles").notNull().default(`["view", "systemAdmin"]`), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
|
||||
//roles: text("roles").notNull().default(`["view", "systemAdmin"]`), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
|
||||
roles: jsonb("roles").notNull().default(["view", "systemAdmin"]), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
|
||||
add_User: text("add_User").default("LST_System").notNull(),
|
||||
add_Date: timestamp("add_Date").defaultNow(),
|
||||
upd_user: text("upd_User").default("LST_System").notNull(),
|
||||
|
||||
33
database/schema/settings.ts
Normal file
33
database/schema/settings.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {text, pgTable, timestamp, uuid, uniqueIndex, jsonb} from "drizzle-orm/pg-core";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {modules} from "./modules.js";
|
||||
|
||||
export const settings = pgTable(
|
||||
"settings",
|
||||
{
|
||||
settings_id: uuid("role_id").defaultRandom().primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
value: text("value").notNull(),
|
||||
description: text("description"),
|
||||
module_id: uuid("module_id")
|
||||
.notNull()
|
||||
.references(() => modules.module_id),
|
||||
roles: jsonb("roles").notNull().default(["systemAdmin"]),
|
||||
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("name").on(table.name),
|
||||
]
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
// export const insertRolesSchema = createInsertSchema(roles, {
|
||||
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
|
||||
// });
|
||||
// Schema for selecting a Expenses - can be used to validate API responses
|
||||
export const selectRolesSchema = createSelectSchema(settings);
|
||||
Reference in New Issue
Block a user