Skip to content

Commit

Permalink
refactor: re-organize code
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 17, 2020
1 parent 40d528d commit f09f4f6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions commands/Migration/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default abstract class MigrationsBase extends BaseCommand {
if (compiledAt.isValid) {
console.log(`${this.colors.magenta('Last compiled at:')} ${compiledAt.toLocaleString(DateTime.DATETIME_MED)}`)
}
console.log('')
}

/**
Expand Down
3 changes: 2 additions & 1 deletion commands/Migration/Rollback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class Migrate extends MigrationsBase {
* Custom connection for running migrations.
*/
@flags.string({ description: 'Define a custom database connection' })
public connection: string = this.db.primaryConnectionName
public connection: string

/**
* Force run migrations in production
Expand Down Expand Up @@ -65,6 +65,7 @@ export default class Migrate extends MigrationsBase {
* Handle command
*/
public async handle (): Promise<void> {
this.connection = this.connection || this.db.primaryConnectionName
const connection = this.db.getRawConnection(this.connection)

const continueMigrations = !this.application.inProduction
Expand Down
4 changes: 3 additions & 1 deletion commands/Migration/Run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class Migrate extends MigrationsBase {
* Custom connection for running migrations.
*/
@flags.string({ description: 'Define a custom database connection' })
public connection: string = this.db.primaryConnectionName
public connection: string

/**
* Force run migrations in production
Expand Down Expand Up @@ -57,7 +57,9 @@ export default class Migrate extends MigrationsBase {
* Handle command
*/
public async handle (): Promise<void> {
this.connection = this.connection || this.db.primaryConnectionName
const connection = this.db.getRawConnection(this.connection)

const continueMigrations = !this.application.inProduction
|| this.force
|| await this.takeProductionConstent()
Expand Down
3 changes: 2 additions & 1 deletion commands/Migration/Status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default class Status extends MigrationsBase {
* Handle command
*/
public async handle (): Promise<void> {
const connection = this.db.getRawConnection(this.connection || this.db.primaryConnectionName)
this.connection = this.connection || this.db.primaryConnectionName
const connection = this.db.getRawConnection(this.connection)

/**
* Ensure the define connection name does exists in the
Expand Down

0 comments on commit f09f4f6

Please sign in to comment.