feat(presence-service): 添加 init-db 命令创建数据库
- 添加 init-db 命令自动创建 rwa_presence 数据库 - 创建数据库后自动运行 prisma db push 创建表结构 - 更新帮助文档 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
784e98f1dc
commit
aa06607c1d
|
|
@ -133,6 +133,16 @@ case "$1" in
|
|||
fi
|
||||
;;
|
||||
|
||||
init-db)
|
||||
log_info "Creating database rwa_presence..."
|
||||
docker exec rwa-postgres psql -U rwa_user -d postgres -c "CREATE DATABASE rwa_presence;" 2>/dev/null || \
|
||||
log_warn "Database may already exist"
|
||||
log_success "Database rwa_presence created (or already exists)"
|
||||
log_info "Running Prisma db push to create tables..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma db push --skip-generate 2>/dev/null || \
|
||||
log_warn "Could not push schema (container may not be running)"
|
||||
;;
|
||||
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
|
|
@ -222,6 +232,7 @@ case "$1" in
|
|||
echo " health - Check service health"
|
||||
echo ""
|
||||
echo "Database Commands:"
|
||||
echo " init-db - Create database and push schema"
|
||||
echo " migrate - Run database migrations (production)"
|
||||
echo " migrate-dev - Run dev migrations"
|
||||
echo " db-push - Push Prisma schema to database"
|
||||
|
|
|
|||
Loading…
Reference in New Issue