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

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

No files matched your search

+1 -1
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"]
+12 -3
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 = [