import { pgTable, timestamp, uuid, varchar } from "drizzle-orm/pg-core"; import { companiesTable } from "./companies"; import { relations } from "drizzle-orm"; export const appsTable = pgTable("apps", { id: uuid("id").defaultRandom().primaryKey(), name: varchar("name").notNull(), fileName: varchar("filename").notNull(), companyId: uuid("company_id") .notNull() .references(() => companiesTable.id), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .defaultNow(), updatedAt: timestamp("updated_at", { withTimezone: true }) .notNull() .defaultNow() .$onUpdate(() => new Date()), }); export const appsRelations = relations(appsTable, ({ one }) => ({ company: one(companiesTable, { fields: [appsTable.companyId], references: [companiesTable.id], }), }));