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: "number" })
    .notNull()
    .references(() => property.id, { onDelete: "cascade" }),

  portfolioId: bigint("portfolio_id", { mode: "number" })
    .notNull()
    .references(() => portfolio.id, { onDelete: "cascade" }),


  createdAt: timestamp("created_at", { precision: 6, withTimezone: true })
    .defaultNow()
    .notNull(),

  updatedAt: timestamp("updated_at", { precision: 6, withTimezone: true })
    .defaultNow()
    .$onUpdate(() => new Date())
    .notNull(),
});
