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

export const nurseriesTable = pgTable("nurseries", {
  id: serial("id").primaryKey(),
  name: text("name").notNull(),
  phone: text("phone"),
  location: text("location"),
  notes: text("notes"),
  balance: numeric("balance", { precision: 15, scale: 2 }).default("0").notNull(),
  createdAt: timestamp("created_at").defaultNow().notNull(),
});

export const insertNurserySchema = createInsertSchema(nurseriesTable).omit({ id: true, createdAt: true, balance: true });
export type InsertNursery = z.infer<typeof insertNurserySchema>;
export type Nursery = typeof nurseriesTable.$inferSelect;
