making uprn unique on epc store

This commit is contained in:
Khalim Conn-Kowlessar 2025-12-21 12:55:24 +00:00
parent 53858c2e3b
commit 3e90bee22a
4 changed files with 4893 additions and 14 deletions

View file

@ -0,0 +1 @@
CREATE UNIQUE INDEX "uq_epc_store_uprn" ON "epc_store" USING btree ("uprn");

File diff suppressed because it is too large Load diff

View file

@ -974,6 +974,13 @@
"when": 1766319125106,
"tag": "0138_neat_havok",
"breakpoints": true
},
{
"idx": 139,
"version": "7",
"when": 1766321608808,
"tag": "0139_skinny_legion",
"breakpoints": true
}
]
}

View file

@ -5,6 +5,7 @@ import {
jsonb,
timestamp,
bigint,
uniqueIndex,
} from "drizzle-orm/pg-core";
// This table stores postcode search results from the OS Places API
@ -23,22 +24,26 @@ export interface EpcApiResponse {
rows?: Record<string, any>;
}
export const epcStore = pgTable("epc_store", {
id: serial("id").primaryKey(),
uprn: bigint("uprn", { mode: "bigint" }),
export const epcStore = pgTable(
"epc_store",
{
id: serial("id").primaryKey(),
uprn: bigint("uprn", { mode: "bigint" }),
// Timestamp for when the EPC API entry was first stored
epcApiCreatedAt: timestamp("epc_api_created_at"),
// Timestamp for when the EPC API entry was first stored
epcApiCreatedAt: timestamp("epc_api_created_at"),
// EPC API response for the UPRN
epcApi: jsonb("epc_api").$type<EpcApiResponse>(),
// EPC API response for the UPRN
epcApi: jsonb("epc_api").$type<EpcApiResponse>(),
// Timestamp for when the EPC page was stored
epcPageCreatedAt: timestamp("epc_page_created_at"),
// Timestamp for when the EPC page was stored
epcPageCreatedAt: timestamp("epc_page_created_at"),
// HTML content of the EPC page
epcPage: text("epc_page"),
// HTML content of the EPC page
epcPage: text("epc_page"),
// RRN of the EPC page
epcPageRrn: text("epc_page_rrn"),
});
// RRN of the EPC page
epcPageRrn: text("epc_page_rrn"),
},
(table) => [uniqueIndex("uq_epc_store_uprn").on(table.uprn)]
);