feat(produser): added the ability to add a prod user by default roles and update if already there

This commit is contained in:
2025-06-09 16:42:49 -05:00
parent ed44b11e5c
commit ad4c9502fa
12 changed files with 2505 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import {
text,
pgTable,
timestamp,
uuid,
uniqueIndex,
jsonb,
} from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { z } from "zod";
export const prodPermissions = pgTable(
"prodPermissions",
{
prodPerm_id: uuid("prodPerm_id").defaultRandom().primaryKey(),
name: text("name").notNull(),
description: text("description").notNull(),
roles: jsonb("roles").default([]),
rolesLegacy: jsonb("rolesLegacy").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("prodPermName").on(table.name),
]
);
// Schema for inserting a user - can be used to validate API requests
// export const insertUsersSchema = createInsertSchema(prodPermissions, {
// name: z
// .string()
// .min(3, { message: "Role name must be longer than 3 characters" }),
// });
// Schema for selecting a Expenses - can be used to validate API responses
export const selectUsersSchema = createSelectSchema(prodPermissions);