Files
ulthon_admin/tests/setup_test_db.sh
augushong 553047025c refactor(install): 种子退役,migrate:run 一条命令完成建表与初始数据
新增 InitDataAlignService 六域对齐(超管/角色/权限节点/配置/快捷入口/商城演示)与 20260909130000 迁移;SystemAdmin 快照以字面量哈希入库;删除种子三件与安装锁依赖,seeds 目录留 .gitkeep;README/tests/规则等 11 处说明同步。

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-09 14:38:10 +00:00

35 lines
1.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 测试数据库初始化(bash / CI 包装器)。
#
# 调用 PHP 运行器 tests/setup_test_db.php,在同一进程内:
# 1. 从 .env 读连接参数(hostname/hostport/username/password/charset/prefix/database)
# 2. 派生测试库名 = {env.database} + '_test'(如 ulthon_admin -> ulthon_admin_test)
# 3. 在同一 MySQL 实例上 CREATE DATABASE IF NOT EXISTS(无需专用 Docker 容器)
# 4. config 级覆盖 connections.main 指向测试库
# 5. php think migrate:run 建系统/框架表 + 全部初始数据(database/migrations/)
# 6. php think scheme:sync 建业务表(app/admin/scheme/)
# 7. 查 information_schema 验证表已落到测试库
#
# 完全参数化:不硬编码 host/port/credentials。MySQL 实例 = .env 指向的那个。
# 详见 tests/README.md。
set -euo pipefail
# 项目根目录(脚本位于 tests/ 下,取上一级)
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
RUNNER="$PROJECT_ROOT/tests/setup_test_db.php"
# 1. 确保 php 在 PATH 上
if ! command -v php >/dev/null 2>&1; then
echo "[错误] PATH 上找不到 php。请安装 PHP 8+ 并加入 PATH。"
exit 1
fi
# 2. 运行 PHP 运行器
echo "==== 运行 setup_test_db.php ===="
php "$RUNNER"
code=$?
echo ""
echo "==== 完成,PHP 退出码 = $code ===="
exit "$code"