property schema

This commit is contained in:
Jun-te Kim 2025-10-17 14:20:48 +00:00
parent 4bf3ec44f2
commit 6c0ff8a1d4

View file

@ -0,0 +1,29 @@
import { pgTable, uuid, text, bigint, timestamp } from "drizzle-orm/pg-core";
import { InferModel } from "drizzle-orm";
import { property } from "../property";
import { portfolio } from "../portfolio";
export const propertyStatusTracker = pgTable("property_status_tracker", {
id: uuid("id").defaultRandom().primaryKey(),
hubspotDealId: text("hubspot_deal_id").notNull(),
// foreign keys
propertyId: bigint("property_id", { mode: "bigint" })
.notNull()
.references(() => property.id, { onDelete: "cascade" }),
portfolioId: bigint("portfolio_id", { mode: "bigint" })
.notNull()
.references(() => portfolio.id, { onDelete: "cascade" }),
hubspotPipelineId: text("hubspot_pipeline_id").notNull(),
createdAt: timestamp("created_at", { precision: 6, withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", { precision: 6, withTimezone: true })
.defaultNow()
.$onUpdate(() => new Date())
.notNull(),
});