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

export const orderImport = pgTable("order_import", {
	id: uuid("id").defaultRandom().primaryKey(),
	receivingPlantId: text("receiving_plant_id").notNull(),
	documentName: text("documentName"),
	sender: text("sender"),
	customerId: text("customer_id"),
	invoiceAddressId: text("invoice_address_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 orderImportSchema = createSelectSchema(orderImport);
export const newOrderImportSchema = createInsertSchema(orderImport);

export type OrderImport = z.infer<typeof orderImportSchema>;
export type NewOrderImport = z.infer<typeof newOrderImportSchema>;
