Skip to content

Commit 944d24c

Browse files
committed
根据是否有migrations文件切换指令
1 parent 8e31ef9 commit 944d24c

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

templates/prisma/migrations/20251130164417_create_table_user/migration.sql

Lines changed: 0 additions & 11 deletions
This file was deleted.

templates/prisma/migrations/migration_lock.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

templates/scripts/start.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { execSync, spawn } from 'node:child_process';
2+
import { existsSync } from 'node:fs';
3+
import path from 'node:path';
24
import process from 'node:process';
35

46
execSync('docker compose -f docker-compose.yml up --wait', { stdio: 'inherit' });
57
const healthCheck = execSync('docker compose -f docker-compose.yml ps', { encoding: 'utf8' });
68
if (healthCheck.includes('unhealthy')) process.exit(1);
79

810
execSync('npx prisma generate', { stdio: 'inherit' });
9-
execSync('npx prisma migrate deploy', { stdio: 'inherit' });
11+
if (existsSync(path.resolve('prisma', 'migrations'))) {
12+
execSync('npx prisma migrate deploy', { stdio: 'inherit' });
13+
} else if (existsSync(path.resolve('prisma', 'schema.prisma'))) {
14+
execSync('npx prisma db push', { stdio: 'inherit' });
15+
}
1016
const api = spawn('node', ['--import', 'tsx/esm', '--watch', 'src/web.ts'], { stdio: 'inherit' });
1117
const cron = spawn('npx', ['aomex', 'cron:start'], { stdio: 'inherit' });
1218

0 commit comments

Comments
 (0)