fix: migration 使用 IF NOT EXISTS 防止重复创建 + clean 去掉 --remove-orphans

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-30 00:37:29 -08:00
parent 4a803ea008
commit 08cf4681f2
2 changed files with 3 additions and 3 deletions

View File

@ -1046,7 +1046,7 @@ services_clean() {
# Step 1: Stop and remove containers, networks, images, and volumes via docker compose
log_step "Stopping and removing containers, images, and volumes..."
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" down --rmi all --volumes --remove-orphans 2>/dev/null || true
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" down --rmi all --volumes 2>/dev/null || true
# Step 2: Remove any remaining containers by name (in case compose down missed them)
log_step "Removing any remaining containers..."

View File

@ -3,7 +3,7 @@
-- 由 Debezium heartbeat.action.query 自动更新
-- 防止因业务表长期无写入导致 WAL 堆积
CREATE TABLE "debezium_heartbeat" (
CREATE TABLE IF NOT EXISTS "debezium_heartbeat" (
"id" INTEGER NOT NULL DEFAULT 1,
"ts" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
@ -11,4 +11,4 @@ CREATE TABLE "debezium_heartbeat" (
);
-- 插入初始记录
INSERT INTO "debezium_heartbeat" ("id", "ts") VALUES (1, NOW());
INSERT INTO "debezium_heartbeat" ("id", "ts") VALUES (1, NOW()) ON CONFLICT ("id") DO NOTHING;