58 lines
1.9 KiB
SQL
58 lines
1.9 KiB
SQL
CREATE TABLE "ding_workflow_snapshots" (
|
|
"process_instance_id" TEXT NOT NULL,
|
|
"business_id" TEXT,
|
|
"title" TEXT,
|
|
"result" TEXT,
|
|
"originator_user_id" TEXT,
|
|
"originator_dept_id" TEXT,
|
|
"originator_dept_name" TEXT,
|
|
"status" TEXT NOT NULL,
|
|
"biz_action" TEXT,
|
|
"process_code" TEXT,
|
|
"flow_type" TEXT,
|
|
"joined_at_raw" TEXT,
|
|
"source_created_at_raw" TEXT,
|
|
"source_updated_at_raw" TEXT,
|
|
"source_finished_at_raw" TEXT,
|
|
"is_ongoing" BOOLEAN NOT NULL DEFAULT false,
|
|
"scheme_field_count" INTEGER NOT NULL DEFAULT 0,
|
|
"task_count" INTEGER NOT NULL DEFAULT 0,
|
|
"active_task_count" INTEGER NOT NULL DEFAULT 0,
|
|
"latest_task_status" TEXT,
|
|
"latest_task_at_raw" TEXT,
|
|
"synced_at" TIMESTAMP(3) NOT NULL,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "ding_workflow_snapshots_pkey" PRIMARY KEY ("process_instance_id")
|
|
);
|
|
|
|
CREATE TABLE "ding_workflow_sync_states" (
|
|
"id" TEXT NOT NULL,
|
|
"status" TEXT NOT NULL DEFAULT 'idle',
|
|
"source_cursor_raw" TEXT,
|
|
"last_started_at" TIMESTAMP(3),
|
|
"last_completed_at" TIMESTAMP(3),
|
|
"last_error" TEXT,
|
|
"lease_owner" TEXT,
|
|
"lease_expires_at" TIMESTAMP(3),
|
|
"rows_upserted" INTEGER NOT NULL DEFAULT 0,
|
|
"current_ongoing_count" INTEGER NOT NULL DEFAULT 0,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "ding_workflow_sync_states_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
CREATE INDEX "ding_workflow_snapshots_ongoing_updated_idx"
|
|
ON "ding_workflow_snapshots"("is_ongoing", "source_updated_at_raw");
|
|
|
|
CREATE INDEX "ding_workflow_snapshots_status_idx"
|
|
ON "ding_workflow_snapshots"("status");
|
|
|
|
CREATE INDEX "ding_workflow_snapshots_department_idx"
|
|
ON "ding_workflow_snapshots"("originator_dept_name");
|
|
|
|
CREATE INDEX "ding_workflow_sync_states_lease_idx"
|
|
ON "ding_workflow_sync_states"("lease_expires_at");
|