1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
CREATE TABLE "code_groups" (
"id" serial PRIMARY KEY NOT NULL,
"group_id" varchar(50) NOT NULL,
"description" varchar(100) NOT NULL,
"code_format" varchar(50),
"expressions" text,
"control_type" varchar(20) NOT NULL,
"is_active" boolean DEFAULT true,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "code_groups_group_id_unique" UNIQUE("group_id")
);
--> statement-breakpoint
CREATE TABLE "combo_box_options" (
"id" serial PRIMARY KEY NOT NULL,
"combo_box_setting_id" integer NOT NULL,
"code" varchar(50) NOT NULL,
"description" varchar(200) NOT NULL,
"remark" text,
"sort_order" integer DEFAULT 0,
"is_active" boolean DEFAULT true,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "combo_box_settings" (
"id" serial PRIMARY KEY NOT NULL,
"code_group_id" integer NOT NULL,
"code" varchar(50) NOT NULL,
"description" varchar(200) NOT NULL,
"remark" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "document_class_options_new" (
"id" serial PRIMARY KEY NOT NULL,
"document_class_id" integer NOT NULL,
"option_value" varchar(100) NOT NULL,
"option_code" varchar(50),
"sort_order" integer DEFAULT 0,
"is_active" boolean DEFAULT true,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "document_classes" (
"id" serial PRIMARY KEY NOT NULL,
"code" varchar(50) NOT NULL,
"value" varchar(100),
"description" varchar(200) NOT NULL,
"code_group_id" integer,
"is_active" boolean DEFAULT true,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "document_classes_code_unique" UNIQUE("code")
);
--> statement-breakpoint
CREATE TABLE "document_number_type_configs" (
"id" serial PRIMARY KEY NOT NULL,
"document_number_type_id" integer NOT NULL,
"code_group_id" integer,
"document_class_id" integer,
"sdq" integer NOT NULL,
"description" varchar(200),
"remark" text,
"is_active" boolean DEFAULT true,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "document_number_types" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar(100) NOT NULL,
"description" varchar(200),
"is_active" boolean DEFAULT true,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "document_number_types_name_unique" UNIQUE("name")
);
--> statement-breakpoint
ALTER TABLE "combo_box_options" ADD CONSTRAINT "combo_box_options_combo_box_setting_id_combo_box_settings_id_fk" FOREIGN KEY ("combo_box_setting_id") REFERENCES "public"."combo_box_settings"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "combo_box_settings" ADD CONSTRAINT "combo_box_settings_code_group_id_code_groups_id_fk" FOREIGN KEY ("code_group_id") REFERENCES "public"."code_groups"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_class_options_new" ADD CONSTRAINT "document_class_options_new_document_class_id_document_classes_id_fk" FOREIGN KEY ("document_class_id") REFERENCES "public"."document_classes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_classes" ADD CONSTRAINT "document_classes_code_group_id_code_groups_id_fk" FOREIGN KEY ("code_group_id") REFERENCES "public"."code_groups"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_number_type_configs" ADD CONSTRAINT "document_number_type_configs_document_number_type_id_document_number_types_id_fk" FOREIGN KEY ("document_number_type_id") REFERENCES "public"."document_number_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_number_type_configs" ADD CONSTRAINT "document_number_type_configs_code_group_id_code_groups_id_fk" FOREIGN KEY ("code_group_id") REFERENCES "public"."code_groups"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_number_type_configs" ADD CONSTRAINT "document_number_type_configs_document_class_id_document_classes_id_fk" FOREIGN KEY ("document_class_id") REFERENCES "public"."document_classes"("id") ON DELETE no action ON UPDATE no action;
|