59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# 在生产服务器上更新课程封面
|
|
|
|
SERVER_IP="120.55.112.195"
|
|
SERVER_USER="root"
|
|
SERVER_PASS="yangyichenYANGYICHENkaifa859"
|
|
|
|
sshpass -p "$SERVER_PASS" ssh -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP << 'REMOTE_SCRIPT'
|
|
cd /var/www/wildgrowth-backend/backend
|
|
|
|
# 更新课程封面
|
|
npx ts-node -e "
|
|
import { PrismaClient } from '@prisma/client';
|
|
const prisma = new PrismaClient();
|
|
|
|
(async () => {
|
|
try {
|
|
const courseId = 'course_vertical_001';
|
|
const coverImage = 'images/a0c457c5-4a4c-4cd1-9d17-641e400ab875.PNG';
|
|
|
|
console.log('🚀 开始更新课程封面...');
|
|
console.log('课程ID:', courseId);
|
|
console.log('封面:', coverImage);
|
|
|
|
const course = await prisma.course.findUnique({
|
|
where: { id: courseId },
|
|
select: { id: true, title: true, coverImage: true },
|
|
});
|
|
|
|
if (!course) {
|
|
console.error('❌ 课程不存在');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('当前封面:', course.coverImage || 'null');
|
|
|
|
const updated = await prisma.course.update({
|
|
where: { id: courseId },
|
|
data: { coverImage },
|
|
select: { id: true, title: true, coverImage: true },
|
|
});
|
|
|
|
console.log('✅ 更新成功!');
|
|
console.log('新封面:', updated.coverImage);
|
|
} catch (error) {
|
|
console.error('❌ 更新失败:', error);
|
|
process.exit(1);
|
|
} finally {
|
|
await prisma.\$disconnect();
|
|
}
|
|
})();
|
|
"
|
|
|
|
# 重启PM2服务
|
|
pm2 restart wildgrowth-api
|
|
|
|
echo "✅ 完成!"
|
|
REMOTE_SCRIPT
|