feat: Install sqlx-cli if not present and run database migrations during setup
This commit is contained in:
@@ -238,9 +238,14 @@ RestartSec=5
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
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
|
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
|
systemctl daemon-reload
|
||||||
|
|||||||
Reference in New Issue
Block a user