import { pgTable, uuid, varchar, timestamp } from "drizzle-orm/pg-core"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { companies } from "./companies"; export const branches = pgTable("branches", { id: uuid("id").primaryKey().defaultRandom(), companyId: uuid("company_id") .notNull() .references(() => companies.id, { onDelete: "cascade" }), name: varchar("name", { length: 255 }).notNull(), address: varchar("address", { length: 500 }), city: varchar("city", { length: 100 }), country: varchar("country", { length: 100 }), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), }); // Zod schemas for validation export const insertBranchSchema = createInsertSchema(branches); export const selectBranchSchema = createSelectSchema(branches); // Type exports export type Branch = typeof branches.$inferSelect; export type NewBranch = typeof branches.$inferInsert;