* @inheritDoc
(diff: { up: string[]; down: string[] }, path?: string, name?: string)
| 18 | * @inheritDoc |
| 19 | */ |
| 20 | async generate(diff: { up: string[]; down: string[] }, path?: string, name?: string): Promise<[string, string]> { |
| 21 | const { fs } = await import('@mikro-orm/core/fs-utils'); |
| 22 | /* v8 ignore next */ |
| 23 | const defaultPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path!; |
| 24 | path = fs.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath); |
| 25 | fs.ensureDir(path); |
| 26 | const timestamp = new Date().toISOString().replace(/[-T:]|\.\d{3}z$/gi, ''); |
| 27 | const className = this.namingStrategy.classToMigrationName(timestamp, name); |
| 28 | const fileName = `${this.options.fileName!(timestamp, name)}.${this.options.emit}`; |
| 29 | const ret = await this.generateMigrationFile(className, diff); |
| 30 | await fs.writeFile(path + '/' + fileName, ret, { flush: true }); |
| 31 | |
| 32 | return [ret, fileName]; |
| 33 | } |
| 34 | |
| 35 | /** @inheritDoc */ |
| 36 | /* v8 ignore next */ |
nothing calls this directly
no test coverage detected