feat(cc-052): run drizzle migrations at startup

This commit is contained in:
admin-valentin 2026-08-01 10:32:02 +00:00
parent 2408925264
commit c923d6a042

View file

@ -4,7 +4,9 @@ import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { Logger } from 'nestjs-pino';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { migrate } from 'drizzle-orm/node-postgres/migrator';
import { AppModule } from './app.module';
import { db } from './db/client';
const REQUIRED_ENV_VARS = [
'DATABASE_URL',
@ -26,6 +28,9 @@ function validateEnv(): void {
async function bootstrap() {
validateEnv();
// Apply pending DB migrations before accepting traffic
await migrate(db, { migrationsFolder: './drizzle' });
const app = await NestFactory.create(AppModule, { bufferLogs: true });
app.useLogger(app.get(Logger));
app.use(helmet());