mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
add unique index on uprn, element, aspect type, element instance
This commit is contained in:
parent
09e9addfd0
commit
aac478d8fd
1 changed files with 21 additions and 15 deletions
|
|
@ -5,28 +5,34 @@ import {
|
|||
pgTable,
|
||||
integer,
|
||||
bigint,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { element } from "./element";
|
||||
import { aspectType } from "./aspect_type";
|
||||
|
||||
|
||||
export const assetCondition = pgTable("asset_condition", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
export const assetCondition = pgTable(
|
||||
"asset_condition",
|
||||
{
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
|
||||
uprn: bigint("uprn", { mode: "number" }).notNull(),
|
||||
uprn: bigint("uprn", { mode: "number" }).notNull(),
|
||||
|
||||
element: element("element").notNull(),
|
||||
aspectType: aspectType("aspect_type").notNull(),
|
||||
element: element("element").notNull(),
|
||||
aspectType: aspectType("aspect_type").notNull(),
|
||||
elementInstance: integer("element_instance"),
|
||||
|
||||
value: text("value"),
|
||||
value: text("value"),
|
||||
|
||||
quantity: integer("quantity"),
|
||||
installDate: date("install_date"),
|
||||
renewalYear: integer("renewal_year"),
|
||||
quantity: integer("quantity"),
|
||||
installDate: date("install_date"),
|
||||
renewalYear: integer("renewal_year"),
|
||||
|
||||
elementInstance: integer("element_instance"),
|
||||
|
||||
sourceSystem: text("source_system"),
|
||||
comments: text("comments"),
|
||||
});
|
||||
sourceSystem: text("source_system"),
|
||||
comments: text("comments"),
|
||||
},
|
||||
(t) => ({
|
||||
uniq: uniqueIndex("asset_condition_uprn_element_aspect_instance")
|
||||
.on(t.uprn, t.element, t.aspectType, t.elementInstance),
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue