assessment-model/src/app/db/schema/uploaded_files.ts
2026-06-09 13:56:52 +00:00

94 lines
No EOL
2.4 KiB
TypeScript

import { bigint, bigserial, pgEnum, pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { user } from "./users";
export const fileType = pgEnum("file_type", [
// Assessment
"photo_pack",
"site_note",
"rd_sap_site_note",
"pas_2023_ventilation",
"pas_2023_condition",
"pas_significance",
"par_photo_pack",
"pas_2023_property",
"pas_2023_occupancy",
"ecmk_site_note",
"ecmk_rd_sap_site_note",
"ecmk_survey_xml",
// Contractor install documentation
// Photos
"pre_photo",
"mid_photo",
"post_photo",
"loft_hatch_photo",
"dmev_photos",
"door_undercut_photos",
"trickle_vent_photos",
// Pre-installation
"pre_installation_building_inspection",
"point_of_work_risk_assessment",
// Compliance & lodgement
"claim_of_compliance",
"mcs_compliance_certificate",
"certificate_of_conformity",
"minor_works_electrical_certificate",
"trustmark_licence_numbers",
"operative_competency",
// Ventilation
"ventilation_assessment_checklist",
"anemometer_readings",
"commissioning_records",
"part_f_ventilation_document",
// Handover & warranties
"handover_pack",
"insurance_guarantee",
"workmanship_warranty",
"g98_notification",
// Qualifications & other
"installer_qualifications",
"installer_feedback",
"contractor_other",
// MagicPlan
"magic_plan_json",
// Coordination
"improvement_option_evaluation",
"medium_term_improvement_plan",
// Design
"retrofit_design_doc",
// Audit
"ventilation_audit",
// Other
"other"
]);
export const fileSource = pgEnum("file_source", [
"pas hub",
"sharepoint",
"hubspot",
"ecmk",
"contractor",
"magic_plan",
"coordination_hub",
"audit_generator"
]);
export const uploadedFiles = pgTable(
"uploaded_files",
{
id: bigserial("id", { mode: "bigint" }).primaryKey(),
s3FileBucket: text("s3_file_bucket").notNull(),
s3FileKey: text("s3_file_key").notNull(),
s3UploadTimestamp: timestamp("s3_upload_timestamp", {
withTimezone: true
}).notNull(),
landlordPropertyId: text("landlord_property_id"),
uprn: bigint("uprn", { mode: "bigint" }),
hubsotDealId: text("hubspot_deal_id"),
hubspotListingId: bigint("hubspot_listing_id", { mode: "bigint" }),
fileType: fileType("file_type"),
source: fileSource("file_source"),
measureName: text("measure_name"),
uploadedBy: bigint("uploaded_by", { mode: "bigint" }).references(() => user.id),
}
);