diff --git a/src/app.module.ts b/src/app.module.ts index 3f4bd98..865fc2e 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -11,15 +11,19 @@ import { SequelizeModule } from '@nestjs/sequelize'; envFilePath: ['.env.local', '.env'], isGlobal: true, }), - SequelizeModule.forRoot({ - dialect: 'mysql', - host: process.env.DB_HOST, - port: Number(process.env.DB_PORT), - username: process.env.DB_USER, - password: process.env.DB_PASS, - database: process.env.DB_NAME, - autoLoadModels: true, - synchronize: false, + SequelizeModule.forRootAsync({ + imports: [ConfigModule], + inject: [ConfigService], + useFactory: (configService: ConfigService) => ({ + dialect: 'mysql', + host: configService.get('DB_HOST'), + port: configService.get('DB_PORT'), + username: configService.get('DB_USER'), + password: configService.get('DB_PASS'), + database: configService.get('DB_NAME'), + autoLoadModels: true, + synchronize: true, // Включите обратно для синхронизации + }), }), BlacklistModule, ],