fix(backend): run prisma db push on container entrypoint and safeguard MenuService init
All checks were successful
Deploy Canina / deploy (push) Successful in 52s
All checks were successful
Deploy Canina / deploy (push) Successful in 52s
This commit is contained in:
parent
2c452215c3
commit
7203915e15
@ -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
|
COPY --chown=node:node --from=builder /app/prisma/scientificTerms.ts ./prisma/scientificTerms.ts
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
USER node
|
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"]
|
||||||
|
|||||||
@ -8,12 +8,21 @@ export class MenuService implements OnModuleInit {
|
|||||||
constructor(private prisma: PrismaService) {}
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
async onModuleInit() {
|
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() {
|
private async seedIfEmpty() {
|
||||||
const count = await this.prisma.menuItem.count();
|
try {
|
||||||
if (count > 0) return;
|
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
|
// Seed with current site navigation
|
||||||
const headerItems = [
|
const headerItems = [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user