46 lines
1.7 KiB
SQL
46 lines
1.7 KiB
SQL
CREATE TABLE "document_sequences" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"branch_id" text DEFAULT '' NOT NULL,
|
|
"document_type" text NOT NULL,
|
|
"prefix" text NOT NULL,
|
|
"period" text NOT NULL,
|
|
"current_number" integer DEFAULT 0 NOT NULL,
|
|
"padding_length" integer DEFAULT 3 NOT NULL,
|
|
"is_active" boolean DEFAULT true NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "ms_options" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"category" text NOT NULL,
|
|
"code" text NOT NULL,
|
|
"label" text NOT NULL,
|
|
"value" text,
|
|
"parent_id" text,
|
|
"sort_order" integer DEFAULT 0 NOT NULL,
|
|
"is_active" boolean DEFAULT true NOT NULL,
|
|
"metadata" jsonb,
|
|
"deleted_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "tr_audit_logs" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"branch_id" text,
|
|
"user_id" text NOT NULL,
|
|
"entity_type" text NOT NULL,
|
|
"entity_id" text NOT NULL,
|
|
"action" text NOT NULL,
|
|
"before_data" jsonb,
|
|
"after_data" jsonb,
|
|
"request_id" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "document_sequences_org_doc_period_branch_idx" ON "document_sequences" USING btree ("organization_id","document_type","period","branch_id");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "ms_options_org_category_code_idx" ON "ms_options" USING btree ("organization_id","category","code"); |