mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Merge pull request #262 from Hestia-Homes/feature/magicplan-tables
Magicplan tables - migration
This commit is contained in:
commit
0eec1d8499
4 changed files with 9335 additions and 15 deletions
74
src/app/db/migrations/0195_jittery_harry_osborn.sql
Normal file
74
src/app/db/migrations/0195_jittery_harry_osborn.sql
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
CREATE TYPE "public"."user_defined_deal_measure_source" AS ENUM('instructed', 'pibi_ordered');--> statement-breakpoint
|
||||
CREATE TABLE "magic_plan_door" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"magic_plan_room_id" bigint NOT NULL,
|
||||
"width_mm" real,
|
||||
"type" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "magic_plan_floor" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"magic_plan_plan_id" bigint NOT NULL,
|
||||
"level" integer
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "magic_plan_plan" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"name" text,
|
||||
"address" text,
|
||||
"postcode" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "magic_plan_room" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"magic_plan_floor_id" bigint NOT NULL,
|
||||
"name" text,
|
||||
"width_m" real,
|
||||
"length_m" real,
|
||||
"area_m2" real
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "magic_plan_window" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"magic_plan_room_id" bigint NOT NULL,
|
||||
"width_m" real,
|
||||
"height_m" real,
|
||||
"area_m2" real,
|
||||
"opening_type" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "survey_requests" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"hubspot_deal_id" text NOT NULL,
|
||||
"portfolio_id" bigint NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"status" text DEFAULT 'pending' NOT NULL,
|
||||
"requested_by" bigint NOT NULL,
|
||||
"requested_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"fulfilled_at" timestamp with time zone
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "user_defined_deal_measures" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"hubspot_deal_id" text NOT NULL,
|
||||
"measure_name" text NOT NULL,
|
||||
"source" "user_defined_deal_measure_source" NOT NULL,
|
||||
"created_by_user_id" bigint NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"pushed_at" timestamp with time zone,
|
||||
"confirmed_in_hubspot_at" timestamp with time zone,
|
||||
"notes" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "hubspot_deal_data" ADD COLUMN "domna_survey_required" boolean;--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_door" ADD CONSTRAINT "magic_plan_door_magic_plan_room_id_magic_plan_room_id_fk" FOREIGN KEY ("magic_plan_room_id") REFERENCES "public"."magic_plan_room"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_floor" ADD CONSTRAINT "magic_plan_floor_magic_plan_plan_id_magic_plan_plan_id_fk" FOREIGN KEY ("magic_plan_plan_id") REFERENCES "public"."magic_plan_plan"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_room" ADD CONSTRAINT "magic_plan_room_magic_plan_floor_id_magic_plan_floor_id_fk" FOREIGN KEY ("magic_plan_floor_id") REFERENCES "public"."magic_plan_floor"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "magic_plan_window" ADD CONSTRAINT "magic_plan_window_magic_plan_room_id_magic_plan_room_id_fk" FOREIGN KEY ("magic_plan_room_id") REFERENCES "public"."magic_plan_room"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "survey_requests" ADD CONSTRAINT "survey_requests_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "survey_requests" ADD CONSTRAINT "survey_requests_requested_by_user_id_fk" FOREIGN KEY ("requested_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "user_defined_deal_measures" ADD CONSTRAINT "user_defined_deal_measures_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "idx_survey_requests_deal_id" ON "survey_requests" USING btree ("hubspot_deal_id");--> statement-breakpoint
|
||||
CREATE INDEX "idx_survey_requests_portfolio_id" ON "survey_requests" USING btree ("portfolio_id");--> statement-breakpoint
|
||||
CREATE INDEX "idx_user_defined_deal_measures_deal_id" ON "user_defined_deal_measures" USING btree ("hubspot_deal_id");--> statement-breakpoint
|
||||
CREATE INDEX "idx_user_defined_deal_measures_source" ON "user_defined_deal_measures" USING btree ("source");
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
CREATE TABLE "survey_requests" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"hubspot_deal_id" text NOT NULL,
|
||||
"portfolio_id" bigint NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"status" text DEFAULT 'pending' NOT NULL,
|
||||
"requested_by" bigint NOT NULL,
|
||||
"requested_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"fulfilled_at" timestamp with time zone
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "survey_requests" ADD CONSTRAINT "survey_requests_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "public"."portfolio"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "survey_requests" ADD CONSTRAINT "survey_requests_requested_by_user_id_fk" FOREIGN KEY ("requested_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "idx_survey_requests_deal_id" ON "survey_requests" USING btree ("hubspot_deal_id");--> statement-breakpoint
|
||||
CREATE INDEX "idx_survey_requests_portfolio_id" ON "survey_requests" USING btree ("portfolio_id");
|
||||
9254
src/app/db/migrations/meta/0195_snapshot.json
Normal file
9254
src/app/db/migrations/meta/0195_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1366,6 +1366,13 @@
|
|||
"when": 1778100000000,
|
||||
"tag": "0194_user_defined_deal_measures",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 195,
|
||||
"version": "7",
|
||||
"when": 1778078457355,
|
||||
"tag": "0195_jittery_harry_osborn",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue