uat-doc-perfix

This commit is contained in:
phaichayon
2026-06-30 14:48:34 +07:00
parent 9698228c51
commit 47eac3badc
28 changed files with 2518 additions and 996 deletions

View File

@@ -0,0 +1,28 @@
ALTER TABLE "document_sequences"
ADD COLUMN "product_type" text DEFAULT 'all' NOT NULL;
--> statement-breakpoint
ALTER TABLE "document_sequences"
ADD COLUMN "format" text DEFAULT '{prefix}{period}-{running}' NOT NULL;
--> statement-breakpoint
ALTER TABLE "document_sequences"
ADD COLUMN "reset_policy" text DEFAULT 'period' NOT NULL;
--> statement-breakpoint
UPDATE "document_sequences"
SET
"product_type" = CASE
WHEN "document_type" = 'quotation' THEN 'legacy'
ELSE 'all'
END,
"format" = '{prefix}{period}-{running}',
"reset_policy" = 'period';
--> statement-breakpoint
DROP INDEX "document_sequences_org_doc_period_branch_idx";
--> statement-breakpoint
CREATE UNIQUE INDEX "document_sequences_org_branch_product_doc_period_idx"
ON "document_sequences" USING btree (
"organization_id",
"branch_id",
"product_type",
"document_type",
"period"
);