import {
    text,
    pgTable,
    numeric,
    timestamp,
    uuid,
    integer,
} from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { z } from "zod";

export const siloAdjustments = pgTable(
    "siloAdjustments",
    {
        siloAdjust_id: uuid("siloAdjust_id").defaultRandom().primaryKey(),
        warehouseID: integer("level"),
        locationID: integer("locationID"),
        currentStockLevel: numeric("currentStockLevel"),
        newLevel: numeric("newLevel"),
        comment: text("comment").default(""),
        dateAdjusted: timestamp("dateAdjusted").defaultNow(),
        lastDateAdjusted: timestamp("lastDateAdjusted").defaultNow(),
        commentAddedBy: text("commentAddedBy"),
        commentDate: text("commentDate"),
        commentKey: text("commentKey"),
        add_user: text("add_user").default("LST_Serivce"),
    },
    (table) => [
        // uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
        // uniqueIndex("role_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(siloAdjustments);
