fix(backend): run prisma db push on container entrypoint and safeguard MenuService init
All checks were successful
Deploy Canina / deploy (push) Successful in 52s

This commit is contained in:
parsa aghaei 2026-08-22 11:14:00 +03:30
parent 2c452215c3
commit 7203915e15
2 changed files with 13 additions and 4 deletions

View File

@ -42,4 +42,4 @@ COPY --chown=node:node --from=builder /app/prisma/tsconfig.seed.json ./prisma/ts
COPY --chown=node:node --from=builder /app/prisma/scientificTerms.ts ./prisma/scientificTerms.ts
EXPOSE 3000
USER node
CMD ["sh", "-c", "npx prisma migrate deploy && if [ -f dist/src/main.js ]; then node dist/src/main.js; else node dist/main.js; fi"]
CMD ["sh", "-c", "npx prisma db push --skip-generate && if [ -f dist/src/main.js ]; then node dist/src/main.js; else node dist/main.js; fi"]

View File

@ -8,12 +8,21 @@ export class MenuService implements OnModuleInit {
constructor(private prisma: PrismaService) {}
async onModuleInit() {
await this.seedIfEmpty();
try {
await this.seedIfEmpty();
} catch (err) {
console.warn('[MenuService] seedIfEmpty skipped during module init:', err?.message || err);
}
}
private async seedIfEmpty() {
const count = await this.prisma.menuItem.count();
if (count > 0) return;
try {
const count = await this.prisma.menuItem.count();
if (count > 0) return;
} catch (err) {
console.warn('[MenuService] menuItem table not accessible yet:', err?.message || err);
return;
}
// Seed with current site navigation
const headerItems = [