Skip to content

Commit

Permalink
feat: add migrations transaction option to connection options (#5147)
Browse files Browse the repository at this point in the history
* feat: add migrations transaction option to connection options

It is the extension of pull request #4629 which allows
 applying same transaction options when running transactions in automatic mode

* feat: add migrations transaction option to connection options

It is the extension of pull request #4629 which allows
applying same transaction options when running transactions in automatic mode

* feat: add migrations transaction option to connection options

It is the extension of pull request #4629 which allows
applying same transaction options when running transactions in automatic mode
  • Loading branch information
mightyYaroslav authored and pleerock committed Nov 27, 2019
1 parent 7160749 commit fb60688
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/using-ormconfig.md
Expand Up @@ -113,6 +113,7 @@ List of available env variables you can set:
* TYPEORM_SYNCHRONIZE
* TYPEORM_DROP_SCHEMA
* TYPEORM_MIGRATIONS_RUN
* TYPEORM_MIGRATIONS_TRANSACTION_MODE
* TYPEORM_ENTITIES
* TYPEORM_MIGRATIONS
* TYPEORM_MIGRATIONS_TABLE_NAME
Expand Down
1 change: 1 addition & 0 deletions docs/zh_CN/using-ormconfig.md
Expand Up @@ -112,6 +112,7 @@ TYPEORM_ENTITIES = entity/.*js,modules/**/entity/.*js
- TYPEORM_SYNCHRONIZE
- TYPEORM_DROP_SCHEMA
- TYPEORM_MIGRATIONS_RUN
- TYPEORM_MIGRATIONS_TRANSACTION_MODE
- TYPEORM_ENTITIES
- TYPEORM_MIGRATIONS
- TYPEORM_SUBSCRIBERS
Expand Down
5 changes: 5 additions & 0 deletions src/connection/BaseConnectionOptions.ts
Expand Up @@ -47,6 +47,11 @@ export interface BaseConnectionOptions {
*/
readonly migrationsTableName?: string;

/**
* Transaction mode for migrations to run in
*/
readonly migrationsTransactionMode?: "all" | "none" | "each";

/**
* Naming strategy to be used to name tables and columns in the database.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/connection/Connection.ts
Expand Up @@ -202,7 +202,7 @@ export class Connection {

// if option is set - automatically synchronize a schema
if (this.options.migrationsRun)
await this.runMigrations();
await this.runMigrations({ transaction: this.options.migrationsTransactionMode });

} catch (error) {

Expand Down

0 comments on commit fb60688

Please sign in to comment.