#!/bin/bash

echo "=========================================="
echo "数据库迁移 - 添加弹幕字段"
echo "=========================================="
echo ""

# 检查容器是否运行
if ! docker ps | grep -q quanyoumi-app; then
    echo "错误: quanyoumi-app 容器未运行"
    echo "请先启动容器: docker-compose up -d"
    exit 1
fi

echo "正在容器内执行数据库迁移..."
docker exec quanyoumi-app node /app/backend/migrations/index.js

if [ $? -ne 0 ]; then
    echo ""
    echo "迁移失败！"
    exit 1
fi

echo ""
echo "=========================================="
echo "迁移完成！请重启容器使更改生效"
echo "=========================================="
echo ""
echo "重启命令: docker-compose restart"
echo ""
