diff --git a/install.sh b/install.sh index 94ddeab..77be9f2 100644 --- a/install.sh +++ b/install.sh @@ -238,9 +238,14 @@ RestartSec=5 WantedBy=multi-user.target EOF - # 运行数据库迁移 + # 安装 sqlx-cli(若未安装)并运行数据库迁移 + export PATH="$HOME/.cargo/bin:$PATH" + if ! command -v sqlx &> /dev/null; then + cargo install sqlx-cli --no-default-features --features postgres + fi cd $INSTALL_DIR/src/server - DATABASE_URL="postgres://funmc:${DB_PASSWORD}@localhost/funmc" cargo sqlx migrate run + export DATABASE_URL="postgres://funmc:${DB_PASSWORD}@localhost/funmc" + sqlx migrate run # 启动服务 systemctl daemon-reload