Update mikro-orm.config.ts
This commit is contained in:
@@ -6,49 +6,46 @@ import { ConfigService } from "@nestjs/config";
|
|||||||
import { MIKRO_ORM_QUERY_LOGGER, MikroOrmQueryLogger } from "../common/providers/mikro-orm-logger";
|
import { MIKRO_ORM_QUERY_LOGGER, MikroOrmQueryLogger } from "../common/providers/mikro-orm-logger";
|
||||||
|
|
||||||
export const databaseConfig: MikroOrmModuleAsyncOptions = {
|
export const databaseConfig: MikroOrmModuleAsyncOptions = {
|
||||||
providers: [MikroOrmQueryLogger],
|
|
||||||
inject: [ConfigService, MIKRO_ORM_QUERY_LOGGER],
|
inject: [ConfigService, MIKRO_ORM_QUERY_LOGGER],
|
||||||
driver: PostgreSqlDriver,
|
providers: [MikroOrmQueryLogger],
|
||||||
useFactory: (configService: ConfigService, logger: Logger) => ({
|
useFactory: (configService: ConfigService, logger: Logger) => {
|
||||||
driver: PostgreSqlDriver,
|
const DB_PASS = configService.getOrThrow<string>("DB_PASS");
|
||||||
autoLoadEntities: true,
|
const DB_USER = configService.getOrThrow<string>("DB_USER");
|
||||||
dbName: configService.getOrThrow<string>("DB_NAME"),
|
const DB_HOST = configService.getOrThrow<string>("DB_HOST");
|
||||||
user: configService.getOrThrow<string>("DB_USER"),
|
const DB_PORT = configService.getOrThrow<number>("DB_PORT");
|
||||||
password: configService.getOrThrow<string>("DB_PASS"),
|
return {
|
||||||
host: configService.getOrThrow<string>("DB_HOST"),
|
driver: PostgreSqlDriver,
|
||||||
port: configService.getOrThrow<number>("DB_PORT"),
|
autoLoadEntities: true,
|
||||||
debug: configService.getOrThrow<string>("NODE_ENV") !== "production",
|
dbName: configService.getOrThrow<string>("DB_NAME"),
|
||||||
ensureDatabase: { forceCheck: true, create: true, schema: "update" },
|
debug: configService.get<string>("NODE_ENV") !== "production",
|
||||||
// entities: ["./dist/**/*.entity.js"],
|
clientUrl: `postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}`,
|
||||||
// entitiesTs: ["./src/**/*.entity.ts"],
|
ensureDatabase: { forceCheck: true, create: true, schema: "update" },
|
||||||
forceUtcTimezone: true,
|
forceUtcTimezone: true,
|
||||||
timezone: "UTC",
|
pool: {
|
||||||
strict: true,
|
min: 2,
|
||||||
validate: true,
|
max: 15,
|
||||||
pool: {
|
idleTimeoutMillis: 10000,
|
||||||
min: 2, // Minimum number of connections in pool
|
acquireTimeoutMillis: 10000,
|
||||||
max: 10, // Maximum number of connections in pool
|
reapIntervalMillis: 1000,
|
||||||
idleTimeoutMillis: 30000, // 30 seconds before idle connection is closed
|
createTimeoutMillis: 3000,
|
||||||
acquireTimeoutMillis: 10000, // 10 seconds to acquire a connection before throwing error
|
destroyTimeoutMillis: 5000,
|
||||||
reapIntervalMillis: 1000, // How often to check for idle connections
|
},
|
||||||
createTimeoutMillis: 3000, // How long to wait when creating a new connection
|
logger: (message) => logger.debug(message),
|
||||||
destroyTimeoutMillis: 5000, // How long to wait when destroying a connection
|
schemaGenerator: {
|
||||||
},
|
createForeignKey: true,
|
||||||
logger: (message) => logger.debug(message),
|
disableForeignKeys: false,
|
||||||
schemaGenerator: {
|
createIndex: true,
|
||||||
createForeignKey: true,
|
},
|
||||||
disableForeignKeys: false,
|
migrations: {
|
||||||
createIndex: true,
|
path: "./database/migrations",
|
||||||
},
|
pathTs: "./database/migrations",
|
||||||
migrations: {
|
tableName: "migrations",
|
||||||
path: "./database/migrations",
|
transactional: true,
|
||||||
pathTs: "./database/migrations",
|
allOrNothing: true,
|
||||||
tableName: "migrations",
|
dropTables: false,
|
||||||
transactional: true,
|
safe: true,
|
||||||
allOrNothing: true,
|
emit: "ts",
|
||||||
dropTables: false,
|
},
|
||||||
safe: true,
|
};
|
||||||
emit: "ts",
|
},
|
||||||
},
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user