import { pgTable, bigint, timestamp, text, uuid, } from "drizzle-orm/pg-core" import { products } from "./products" import { spaces } from "./spaces" import { tenants } from "./tenants" import { projects } from "./projects" import { authUsers } from "./auth_users" export const movements = pgTable("movements", { id: bigint("id", { mode: "number" }) .primaryKey() .generatedByDefaultAsIdentity(), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .defaultNow(), quantity: bigint("quantity", { mode: "number" }).notNull(), productId: bigint("productId", { mode: "number" }) .notNull() .references(() => products.id), spaceId: bigint("spaceId", { mode: "number" }).references(() => spaces.id), tenant: bigint("tenant", { mode: "number" }) .notNull() .references(() => tenants.id), projectId: bigint("projectId", { mode: "number" }).references( () => projects.id ), notes: text("notes"), serials: text("serials").array(), updatedAt: timestamp("updated_at", { withTimezone: true }), updatedBy: uuid("updated_by").references(() => authUsers.id), }) export type Movement = typeof movements.$inferSelect export type NewMovement = typeof movements.$inferInsert