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

export const forecastImport = pgTable("forecast_import", {
	id: uuid("id").defaultRandom().primaryKey(),
	receivingPlantId: text("receiving_plant_id").notNull(),
	documentName: text("documentName"),
	sender: text("sender"),
	customerId: text("customer_id"),
	rawData: jsonb("raw_data").default([]),
	add_date: timestamp("add_date", { withTimezone: true }).defaultNow(),
	add_user: text("add_user").default("lst-system"),
	upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
	upd_user: text("upd_user").default("lst-system"),
});

export const forecastImportSchema = createSelectSchema(forecastImport);
export const newForecastImportSchema = createInsertSchema(forecastImport);

export type ForecastImport = z.infer<typeof forecastImportSchema>;
export type NeworecastImport = z.infer<typeof newForecastImportSchema>;
