CREATE TABLE "projects" ( "id" serial PRIMARY KEY NOT NULL, "code" varchar(50) NOT NULL, "name" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "contract_items" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "contract_items_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), "contract_id" integer NOT NULL, "item_id" integer NOT NULL, "quantity" integer DEFAULT 1 NOT NULL, "price" numeric(10, 2), "remark" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "contract_items_item_id_unique" UNIQUE("item_id") ); --> statement-breakpoint CREATE TABLE "contracts" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "contracts_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), "vendor_id" integer NOT NULL, "contract_no" varchar(100) NOT NULL, "status" varchar(50) DEFAULT 'ACTIVE' NOT NULL, "start_date" date, "end_date" date, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "contracts_contract_no_unique" UNIQUE("contract_no") ); --> statement-breakpoint CREATE TABLE "forms" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "forms_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), "form_code" varchar(100) NOT NULL, "form_name" varchar(255) NOT NULL, "tag_type" varchar(50) NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "forms_form_code_unique" UNIQUE("form_code") ); --> statement-breakpoint CREATE TABLE "tags" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "tags_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), "contract_item_id" integer NOT NULL, "tag_no" varchar(100) NOT NULL, "tag_type" varchar(50) NOT NULL, "description" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "contract_items" ADD CONSTRAINT "contract_items_contract_id_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."contracts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "contract_items" ADD CONSTRAINT "contract_items_item_id_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "contracts" ADD CONSTRAINT "contracts_vendor_id_vendors_id_fk" FOREIGN KEY ("vendor_id") REFERENCES "public"."vendors"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "tags" ADD CONSTRAINT "tags_contract_item_id_contract_items_id_fk" FOREIGN KEY ("contract_item_id") REFERENCES "public"."contract_items"("id") ON DELETE cascade ON UPDATE no action;