ตรวจสอบแก้ไชสร้างเอกสาร
This commit is contained in:
60
drizzle/0009_notification_delivery_foundation.sql
Normal file
60
drizzle/0009_notification_delivery_foundation.sql
Normal file
@@ -0,0 +1,60 @@
|
||||
ALTER TABLE "app_notification_templates"
|
||||
ADD COLUMN "code" text DEFAULT '' NOT NULL,
|
||||
ADD COLUMN "name" text DEFAULT '' NOT NULL,
|
||||
ADD COLUMN "subject_template" text,
|
||||
ADD COLUMN "body_format" text DEFAULT 'plain' NOT NULL,
|
||||
ADD COLUMN "language" text DEFAULT 'th' NOT NULL,
|
||||
ADD COLUMN "variables" jsonb,
|
||||
ADD COLUMN "version" integer DEFAULT 1 NOT NULL;
|
||||
--> statement-breakpoint
|
||||
UPDATE "app_notification_templates"
|
||||
SET
|
||||
"code" = CASE
|
||||
WHEN "code" = '' THEN replace("event_type", '.', '_') || '_' || "channel"
|
||||
ELSE "code"
|
||||
END,
|
||||
"name" = CASE
|
||||
WHEN "name" = '' THEN "event_type" || ' (' || "channel" || ')'
|
||||
ELSE "name"
|
||||
END,
|
||||
"subject_template" = COALESCE("subject_template", "title_template"),
|
||||
"variables" = COALESCE("variables", '[]'::jsonb);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "app_notification_dispatches" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"organization_id" text NOT NULL,
|
||||
"event_id" text NOT NULL,
|
||||
"template_id" text,
|
||||
"entity_type" text NOT NULL,
|
||||
"entity_id" text NOT NULL,
|
||||
"channel" text NOT NULL,
|
||||
"provider_key" text NOT NULL,
|
||||
"status" text DEFAULT 'pending' NOT NULL,
|
||||
"recipient_to" jsonb NOT NULL,
|
||||
"recipient_cc" jsonb,
|
||||
"recipient_bcc" jsonb,
|
||||
"reply_to" text,
|
||||
"subject" text NOT NULL,
|
||||
"body_text" text NOT NULL,
|
||||
"body_html" text,
|
||||
"attachments" jsonb,
|
||||
"recipient_user_id" text,
|
||||
"recipient_address" text,
|
||||
"requested_by" text NOT NULL,
|
||||
"metadata" jsonb,
|
||||
"last_error" text,
|
||||
"retry_count" integer DEFAULT 0 NOT NULL,
|
||||
"max_retry_count" integer DEFAULT 3 NOT NULL,
|
||||
"last_attempt_at" timestamp with time zone,
|
||||
"sent_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 UNIQUE INDEX "app_notification_dispatches_org_event_channel_recipient_idx"
|
||||
ON "app_notification_dispatches" USING btree (
|
||||
"organization_id",
|
||||
"event_id",
|
||||
"channel",
|
||||
"recipient_address"
|
||||
);
|
||||
89
drizzle/0009_stale_next_avengers.sql
Normal file
89
drizzle/0009_stale_next_avengers.sql
Normal file
@@ -0,0 +1,89 @@
|
||||
CREATE TABLE "app_notification_dispatches" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"organization_id" text NOT NULL,
|
||||
"event_id" text NOT NULL,
|
||||
"template_id" text,
|
||||
"entity_type" text NOT NULL,
|
||||
"entity_id" text NOT NULL,
|
||||
"channel" text NOT NULL,
|
||||
"provider_key" text NOT NULL,
|
||||
"status" text DEFAULT 'pending' NOT NULL,
|
||||
"recipient_to" jsonb NOT NULL,
|
||||
"recipient_cc" jsonb,
|
||||
"recipient_bcc" jsonb,
|
||||
"reply_to" text,
|
||||
"subject" text NOT NULL,
|
||||
"body_text" text NOT NULL,
|
||||
"body_html" text,
|
||||
"attachments" jsonb,
|
||||
"recipient_user_id" text,
|
||||
"recipient_address" text,
|
||||
"requested_by" text NOT NULL,
|
||||
"metadata" jsonb,
|
||||
"last_error" text,
|
||||
"retry_count" integer DEFAULT 0 NOT NULL,
|
||||
"max_retry_count" integer DEFAULT 3 NOT NULL,
|
||||
"last_attempt_at" timestamp with time zone,
|
||||
"sent_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 "crm_document_libraries" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"organization_id" text NOT NULL,
|
||||
"code" text NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"document_type" text NOT NULL,
|
||||
"description" text,
|
||||
"brand" text NOT NULL,
|
||||
"language" text NOT NULL,
|
||||
"product_type" text NOT NULL,
|
||||
"status" text DEFAULT 'active' 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,
|
||||
"deleted_at" timestamp with time zone,
|
||||
"created_by" text NOT NULL,
|
||||
"updated_by" text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "crm_document_library_versions" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"organization_id" text NOT NULL,
|
||||
"library_id" text NOT NULL,
|
||||
"version" text NOT NULL,
|
||||
"file_name" text NOT NULL,
|
||||
"storage_provider" text NOT NULL,
|
||||
"storage_key" text NOT NULL,
|
||||
"mime_type" text NOT NULL,
|
||||
"file_size" integer NOT NULL,
|
||||
"checksum" text NOT NULL,
|
||||
"page_count" integer NOT NULL,
|
||||
"status" text DEFAULT 'draft' NOT NULL,
|
||||
"is_active" boolean DEFAULT false NOT NULL,
|
||||
"published_at" timestamp with time zone,
|
||||
"published_by" text,
|
||||
"archived_at" timestamp with time zone,
|
||||
"archived_by" text,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp with time zone,
|
||||
"created_by" text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
DROP INDEX "document_sequences_org_doc_period_branch_idx";--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "code" text DEFAULT '' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "name" text DEFAULT '' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "subject_template" text;--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "body_format" text DEFAULT 'plain' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "language" text DEFAULT 'th' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "variables" jsonb;--> statement-breakpoint
|
||||
ALTER TABLE "app_notification_templates" ADD COLUMN "version" integer DEFAULT 1 NOT NULL;--> statement-breakpoint
|
||||
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
|
||||
CREATE UNIQUE INDEX "app_notification_dispatches_org_event_channel_recipient_idx" ON "app_notification_dispatches" USING btree ("organization_id","event_id","channel","recipient_address");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "crm_document_libraries_org_code_idx" ON "crm_document_libraries" USING btree ("organization_id","code");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "crm_document_library_versions_library_version_idx" ON "crm_document_library_versions" USING btree ("library_id","version");--> 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");
|
||||
5757
drizzle/meta/0009_snapshot.json
Normal file
5757
drizzle/meta/0009_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -64,6 +64,13 @@
|
||||
"when": 1782913600000,
|
||||
"tag": "0008_document_sequence_scope_refactor",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "7",
|
||||
"when": 1782815675836,
|
||||
"tag": "0009_stale_next_avengers",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user