mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
migrations added
This commit is contained in:
parent
ad557efed0
commit
9cc8ca92ee
11 changed files with 16805 additions and 0 deletions
25
src/app/db/migrations/0106_damp_tombstone.sql
Normal file
25
src/app/db/migrations/0106_damp_tombstone.sql
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
CREATE TABLE "funding_package" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"plan_id" bigint NOT NULL,
|
||||
"scheme" "depth_unit",
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"full_project_funding" real,
|
||||
"total_uplift" real,
|
||||
"full_project_score" real,
|
||||
"partial_project_score" real,
|
||||
"uplift_project_score" real
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "funding_package_measures" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"funding_package_id" bigint NOT NULL,
|
||||
"type" "type" NOT NULL,
|
||||
"material_id" bigint NOT NULL,
|
||||
"innovation_uplift" real,
|
||||
"partial_project_score" real,
|
||||
"uplift_project_score" real
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "funding_package" ADD CONSTRAINT "funding_package_plan_id_plan_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plan"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "funding_package_measures" ADD CONSTRAINT "funding_package_measures_funding_package_id_funding_package_id_fk" FOREIGN KEY ("funding_package_id") REFERENCES "public"."funding_package"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "funding_package_measures" ADD CONSTRAINT "funding_package_measures_material_id_material_id_fk" FOREIGN KEY ("material_id") REFERENCES "public"."material"("id") ON DELETE no action ON UPDATE no action;
|
||||
1
src/app/db/migrations/0107_omniscient_molly_hayes.sql
Normal file
1
src/app/db/migrations/0107_omniscient_molly_hayes.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE "funding_package" RENAME COLUMN "full_project_funding" TO "project_funding";
|
||||
2
src/app/db/migrations/0108_mighty_outlaw_kid.sql
Normal file
2
src/app/db/migrations/0108_mighty_outlaw_kid.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE "funding_package_measures" ALTER COLUMN "material_id" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation" ADD COLUMN "contingency_cost" real;
|
||||
2
src/app/db/migrations/0109_flashy_jane_foster.sql
Normal file
2
src/app/db/migrations/0109_flashy_jane_foster.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE "scenario" ADD COLUMN "contingency" real;--> statement-breakpoint
|
||||
ALTER TABLE "scenario" ADD COLUMN "funding" real;
|
||||
3
src/app/db/migrations/0110_colossal_hulk.sql
Normal file
3
src/app/db/migrations/0110_colossal_hulk.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TYPE "public"."unit_quantity" ADD VALUE 'kwp';--> statement-breakpoint
|
||||
ALTER TABLE "recommendation_materials" ALTER COLUMN "quantity" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation_materials" ALTER COLUMN "quantity_unit" DROP NOT NULL;
|
||||
3337
src/app/db/migrations/meta/0106_snapshot.json
Normal file
3337
src/app/db/migrations/meta/0106_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
3337
src/app/db/migrations/meta/0107_snapshot.json
Normal file
3337
src/app/db/migrations/meta/0107_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
3343
src/app/db/migrations/meta/0108_snapshot.json
Normal file
3343
src/app/db/migrations/meta/0108_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
3355
src/app/db/migrations/meta/0109_snapshot.json
Normal file
3355
src/app/db/migrations/meta/0109_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
3356
src/app/db/migrations/meta/0110_snapshot.json
Normal file
3356
src/app/db/migrations/meta/0110_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
44
src/app/db/schema/funding.ts
Normal file
44
src/app/db/schema/funding.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import {
|
||||
bigserial,
|
||||
timestamp,
|
||||
pgTable,
|
||||
real,
|
||||
pgEnum,
|
||||
bigint,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { InferModel } from "drizzle-orm";
|
||||
import { plan } from "./recommendations";
|
||||
import { material, materialTypeEnum } from "./materials"
|
||||
|
||||
|
||||
export const SchemeEnum: [string, ...string[]] = ["eco4", "gbis", "whlg", "none"];
|
||||
export const Scheme = pgEnum("depth_unit", SchemeEnum);
|
||||
|
||||
// funding package table which has the aggregate level data for the funding package. A funding package will be
|
||||
// tied to a plan
|
||||
export const fundingPackage = pgTable("funding_package", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
planId: bigint("plan_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => plan.id),
|
||||
scheme: Scheme("scheme"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
rojectFunding: real("project_funding"),
|
||||
totalUplift: real("total_uplift"),
|
||||
fullProjectScore: real("full_project_score"),
|
||||
partialProjectScore: real("partial_project_score"),
|
||||
upliftProjectScore: real("uplift_project_score"),
|
||||
})
|
||||
|
||||
export const fundingPackageMeasures = pgTable("funding_package_measures", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
fundingPackageId: bigint("funding_package_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => fundingPackage.id),
|
||||
measure: materialTypeEnum("type").notNull(),
|
||||
materialId: bigint("material_id", { mode: "bigint" })
|
||||
.references(() => material.id), // May be null initially
|
||||
innovationUplift: real("innovation_uplift"),
|
||||
partialProjectScore: real("partial_project_score"),
|
||||
upliftProjectScore: real("uplift_project_score"),
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue