-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmikro-orm-cli.config.ts
More file actions
38 lines (35 loc) · 1.9 KB
/
mikro-orm-cli.config.ts
File metadata and controls
38 lines (35 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@imports-from-feathers';
import type { MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs/typings';
import { FileRecord } from '@modules/files-storage/entity';
import { FileEntity } from '@modules/files/entity';
import { ALL_ENTITIES } from '@shared/domain/entity';
import path from 'path';
const migrationsPath = path.resolve(__dirname, '..', 'migrations', 'mikro-orm');
export const mikroOrmCliConfig: MikroOrmModuleSyncOptions = {
// TODO repeats server module definitions
type: 'mongo',
clientUrl: DB_URL,
password: DB_PASSWORD,
user: DB_USERNAME,
entities: [...ALL_ENTITIES, FileEntity, FileRecord],
allowGlobalContext: true,
/*
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) =>
new NotFoundException(`The requested ${entityName}: ${JSON.stringify(where)} has not been found.`),
*/
migrations: {
tableName: 'migrations', // name of database table with log of executed transactions
path: migrationsPath, // path to the folder with migrations
pathTs: migrationsPath.replace('/dist/apps/server/migrations/mikro-orm', '/apps/server/src/migrations/mikro-orm'), // path to the folder with TS migrations (if used, we should put path to compiled files in `path`)
glob: '!(*.d).{js,ts}', // how to match migration files (all .js and .ts files, but not .d.ts)
transactional: false, // wrap each migration in a transaction
disableForeignKeys: true, // wrap statements with `set foreign_key_checks = 0` or equivalent
allOrNothing: false, // wrap all migrations in master transaction
dropTables: false, // allow to disable table dropping
safe: false, // allow to disable table and column dropping
snapshot: true, // save snapshot when creating new migrations
emit: 'ts', // migration generation mode
// generator: TSMigrationGenerator, // migration generator, e.g. to allow custom formatting
},
};
export default mikroOrmCliConfig;