From bac0228d21b7195065e9cddcc327ae33659c7bcc Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Sun, 1 Jun 2025 13:52:21 +0000
Subject: (대표님) 20250601까지 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 db/migrations/0098_far_sleeper.sql | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 db/migrations/0098_far_sleeper.sql

(limited to 'db/migrations/0098_far_sleeper.sql')

diff --git a/db/migrations/0098_far_sleeper.sql b/db/migrations/0098_far_sleeper.sql
new file mode 100644
index 00000000..f6d20a99
--- /dev/null
+++ b/db/migrations/0098_far_sleeper.sql
@@ -0,0 +1,29 @@
+CREATE TABLE "materials" (
+	"id" serial PRIMARY KEY NOT NULL,
+	"item_code" varchar(100),
+	"item_name" varchar(255) NOT NULL,
+	"description" text,
+	"parent_item_code" varchar(18),
+	"item_level" integer,
+	"delete_flag" varchar(1),
+	"unit_of_measure" varchar(3),
+	"steel_type" varchar(2),
+	"grade_material" varchar(50),
+	"change_date" varchar(8),
+	"base_unit_of_measure" varchar(3),
+	"created_at" timestamp DEFAULT now() NOT NULL,
+	"updated_at" timestamp DEFAULT now() NOT NULL,
+	CONSTRAINT "materials_item_code_unique" UNIQUE("item_code")
+);
+--> statement-breakpoint
+CREATE TABLE "vendor_possible_materials" (
+	"id" serial PRIMARY KEY NOT NULL,
+	"vendor_id" integer NOT NULL,
+	"item_code" varchar(100) NOT NULL,
+	"created_at" timestamp DEFAULT now() NOT NULL,
+	"updated_at" timestamp DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "vendor_possible_materials" ADD CONSTRAINT "vendor_possible_materials_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 "vendor_possible_materials" ADD CONSTRAINT "vendor_possible_materials_item_code_materials_item_code_fk" FOREIGN KEY ("item_code") REFERENCES "public"."materials"("item_code") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE VIEW "public"."vendor_materials_view" AS (select "vendor_possible_materials"."id", "vendor_possible_materials"."vendor_id", "materials"."item_name", "materials"."item_code", "materials"."description", "vendor_possible_materials"."created_at", "vendor_possible_materials"."updated_at" from "vendor_possible_materials" left join "materials" on "vendor_possible_materials"."item_code" = "materials"."item_code");
\ No newline at end of file
-- 
cgit v1.2.3

