feat(cc-052): run drizzle migrations at startup
This commit is contained in:
parent
2408925264
commit
c923d6a042
1 changed files with 5 additions and 0 deletions
|
|
@ -4,7 +4,9 @@ import { ValidationPipe } from '@nestjs/common';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { Logger } from 'nestjs-pino';
|
import { Logger } from 'nestjs-pino';
|
||||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||||
|
import { migrate } from 'drizzle-orm/node-postgres/migrator';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
import { db } from './db/client';
|
||||||
|
|
||||||
const REQUIRED_ENV_VARS = [
|
const REQUIRED_ENV_VARS = [
|
||||||
'DATABASE_URL',
|
'DATABASE_URL',
|
||||||
|
|
@ -26,6 +28,9 @@ function validateEnv(): void {
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
validateEnv();
|
validateEnv();
|
||||||
|
|
||||||
|
// Apply pending DB migrations before accepting traffic
|
||||||
|
await migrate(db, { migrationsFolder: './drizzle' });
|
||||||
|
|
||||||
const app = await NestFactory.create(AppModule, { bufferLogs: true });
|
const app = await NestFactory.create(AppModule, { bufferLogs: true });
|
||||||
app.useLogger(app.get(Logger));
|
app.useLogger(app.get(Logger));
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue