import { bigint, bigserial, date, integer, pgTable, text } from "drizzle-orm/pg-core";
import { element } from "./element";
import { aspectType } from "./aspect_type";
import { InferInsertModel, InferSelectModel } from "drizzle-orm";

export const aspectCondition = pgTable("aspect_condition", {
  id: bigserial("id", { mode: "bigint" }).primaryKey(),

  elementId: bigint("element_id", { mode: "number" })
    .notNull()
    .references(() => element.id),

  aspectType: aspectType("aspect_type").notNull(),
  aspectInstance: integer("aspect_instance").notNull(),

  value: text("value"),
  quantity: integer("quantity"),
  installDate: date("install_date"),
  renewalYear: integer("renewal_year"),
  comments: text("comments"),
});

export type AspectConditionRow =
  InferSelectModel<typeof aspectCondition>;

export type NewAspectConditionRow =
  InferInsertModel<typeof aspectCondition>;

