summaryrefslogtreecommitdiff
path: root/db/migrations/0238_cuddly_puck.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations/0238_cuddly_puck.sql')
-rw-r--r--db/migrations/0238_cuddly_puck.sql88
1 files changed, 88 insertions, 0 deletions
diff --git a/db/migrations/0238_cuddly_puck.sql b/db/migrations/0238_cuddly_puck.sql
new file mode 100644
index 00000000..ca6a7f39
--- /dev/null
+++ b/db/migrations/0238_cuddly_puck.sql
@@ -0,0 +1,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; \ No newline at end of file