summaryrefslogtreecommitdiff
path: root/db/migrations/0359_chunky_skaar.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations/0359_chunky_skaar.sql')
-rw-r--r--db/migrations/0359_chunky_skaar.sql63
1 files changed, 63 insertions, 0 deletions
diff --git a/db/migrations/0359_chunky_skaar.sql b/db/migrations/0359_chunky_skaar.sql
new file mode 100644
index 00000000..c7a7a136
--- /dev/null
+++ b/db/migrations/0359_chunky_skaar.sql
@@ -0,0 +1,63 @@
+CREATE TABLE "pcr_po" (
+ "id" serial PRIMARY KEY NOT NULL,
+ "vendor_id" integer,
+ "pcr_approval_status" varchar(20) DEFAULT 'PENDING',
+ "change_type" varchar(20) DEFAULT 'OTHER',
+ "details" text,
+ "project" varchar(255),
+ "pcr_request_date" date NOT NULL,
+ "po_contract_number" varchar(100) NOT NULL,
+ "rev_item_number" varchar(100),
+ "purchase_contract_manager" varchar(100),
+ "pcr_creator" varchar(100),
+ "po_contract_amount_before" numeric(15, 2),
+ "po_contract_amount_after" numeric(15, 2),
+ "contract_currency" varchar(10) DEFAULT 'KRW',
+ "pcr_reason" text,
+ "details_reason" text,
+ "rejection_reason" text,
+ "pcr_response_date" date,
+ "created_by" integer NOT NULL,
+ "updated_by" integer NOT NULL,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ "updated_at" timestamp DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "pcr_pr" (
+ "id" serial PRIMARY KEY NOT NULL,
+ "material_number" varchar(100) NOT NULL,
+ "material_details" text,
+ "quantity_before" numeric(12, 3),
+ "quantity_after" numeric(12, 3),
+ "weight_before" numeric(12, 3),
+ "weight_after" numeric(12, 3),
+ "subcontractor_weight_before" numeric(12, 3),
+ "subcontractor_weight_after" numeric(12, 3),
+ "supplier_weight_before" numeric(12, 3),
+ "supplier_weight_after" numeric(12, 3),
+ "spec_drawing_before" text,
+ "spec_drawing_after" text,
+ "initial_po_contract_date" date,
+ "spec_change_date" date,
+ "po_contract_modified_date" date,
+ "confirmation_date" date,
+ "design_manager" varchar(100),
+ "po_contract_number" varchar(100) NOT NULL,
+ "created_by" integer NOT NULL,
+ "updated_by" integer NOT NULL,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ "updated_at" timestamp DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "pcr_po" ADD CONSTRAINT "pcr_po_vendor_id_vendors_id_fk" FOREIGN KEY ("vendor_id") REFERENCES "public"."vendors"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "pcr_po" ADD CONSTRAINT "pcr_po_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "pcr_po" ADD CONSTRAINT "pcr_po_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "pcr_pr" ADD CONSTRAINT "pcr_pr_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "pcr_pr" ADD CONSTRAINT "pcr_pr_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "pcr_po_po_contract_number_idx" ON "pcr_po" USING btree ("po_contract_number");--> statement-breakpoint
+CREATE INDEX "pcr_po_vendor_id_idx" ON "pcr_po" USING btree ("vendor_id");--> statement-breakpoint
+CREATE INDEX "pcr_po_approval_status_idx" ON "pcr_po" USING btree ("pcr_approval_status");--> statement-breakpoint
+CREATE INDEX "pcr_po_created_at_idx" ON "pcr_po" USING btree ("created_at");--> statement-breakpoint
+CREATE INDEX "pcr_pr_po_contract_number_idx" ON "pcr_pr" USING btree ("po_contract_number");--> statement-breakpoint
+CREATE INDEX "pcr_pr_material_number_idx" ON "pcr_pr" USING btree ("material_number");--> statement-breakpoint
+CREATE INDEX "pcr_pr_created_at_idx" ON "pcr_pr" USING btree ("created_at"); \ No newline at end of file