Created
September 19, 2021 11:38
-
-
Save rskhan167/3eb4d414dde500c17fd2e3f124846c91 to your computer and use it in GitHub Desktop.
Nestjs Series
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Logger } from '@nestjs/common'; | |
import { Options } from '@mikro-orm/core'; | |
import { SqlHighlighter } from '@mikro-orm/sql-highlighter'; | |
import { TsMorphMetadataProvider } from '@mikro-orm/reflection'; | |
const logger = new Logger('MikroORM'); | |
const config = { | |
entities: ['dist/**/*.entity.js'], | |
entitiesTs: ['src/**/*.entity.ts'], | |
dbName: process.env.DBNAME || 'movie-review', | |
type: 'postgresql', | |
host: 'localhost', | |
port: process.env.DBPORT || 5432, | |
highlighter: new SqlHighlighter(), | |
debug: true, | |
logger: logger.log.bind(logger), | |
password: process.env.DBPASSWORD || 'postgres', | |
metadataProvider: TsMorphMetadataProvider, | |
migrations: { | |
tableName: 'mikro_orm_migrations', // name of database table with log of executed transactions | |
path: './migrations', // path to the folder with migrations | |
pattern: /^[\w-]+\d+\.ts$/, // regex pattern for the migration files | |
transactional: true, // wrap each migration in a transaction | |
disableForeignKeys: true, // wrap statements with `set foreign_key_checks = 0` or equivalent | |
allOrNothing: true, // wrap all migrations in master transaction | |
dropTables: true, // allow to disable table dropping | |
safe: true, // allow to disable table and column dropping | |
emit: 'ts', // migration generation mode | |
} | |
} as Options; | |
export default config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment