feat(produser): added the ability to add a prod user by default roles and update if already there
This commit is contained in:
13
database/migrations/0065_nappy_talos.sql
Normal file
13
database/migrations/0065_nappy_talos.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE "prodPermissions" (
|
||||
"prodPerm_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"description" text NOT NULL,
|
||||
"roles" jsonb DEFAULT '[]'::jsonb,
|
||||
"rolesLegacy" jsonb DEFAULT '[]'::jsonb,
|
||||
"add_User" text DEFAULT 'LST_System' NOT NULL,
|
||||
"add_Date" timestamp DEFAULT now(),
|
||||
"upd_User" text DEFAULT 'LST_System' NOT NULL,
|
||||
"upd_date" timestamp DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "prodPermName" ON "prodPermissions" USING btree ("name");
|
||||
2113
database/migrations/meta/0065_snapshot.json
Normal file
2113
database/migrations/meta/0065_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -456,6 +456,13 @@
|
||||
"when": 1748464203006,
|
||||
"tag": "0064_aberrant_blindfold",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 65,
|
||||
"version": "7",
|
||||
"when": 1749492130639,
|
||||
"tag": "0065_nappy_talos",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
38
database/schema/prodPermissions.ts
Normal file
38
database/schema/prodPermissions.ts
Normal 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);
|
||||
Reference in New Issue
Block a user