test(tenant): 增加本地双站演示数据与跨站验收

This commit is contained in:
yml
2026-11-15 16:33:17 +08:00
parent e994fd9166
commit 899e9155d0
7 changed files with 856 additions and 4 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BACKEND_DIR="${ROOT_DIR}/backend"
MYSQL_DSN="${MYSQL_DSN:-hfb:secret@tcp(127.0.0.1:13306)/hfb_sys?charset=utf8mb4&parseTime=True&loc=Local}"
GOOSE_VERSION="${GOOSE_VERSION:-v3.27.1}"
GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
export GOPROXY
if [[ "${MYSQL_DSN}" == *"multiStatements=true"* ]]; then
GOOSE_DSN="${MYSQL_DSN}"
elif [[ "${MYSQL_DSN}" == *"?"* ]]; then
GOOSE_DSN="${MYSQL_DSN}&multiStatements=true"
else
GOOSE_DSN="${MYSQL_DSN}?multiStatements=true"
fi
printf '[tenant-demo] 执行数据库迁移...\n'
(
cd "${BACKEND_DIR}"
go run "github.com/pressly/goose/v3/cmd/goose@${GOOSE_VERSION}" \
-dir migrations \
mysql "${GOOSE_DSN}" \
up
)
printf '[tenant-demo] 写入双站演示数据...\n'
(
cd "${BACKEND_DIR}"
MYSQL_DSN="${MYSQL_DSN}" go run ./cmd/tenant-demo-seed
)