Skip to content

Commit

Permalink
fix(db-migrator): context is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jan 12, 2020
1 parent 5f508fc commit fbd8880
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/@nodepack/env-migrator/src/lib/Migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export class Migrator {
this.migrationsFolder = migrationsFolder
}

async prepareUp () {
async prepareUp ({
context,
}: UpOptions) {
if (!this.upPrepared) {
this.context = context

await this.setup()

let files = await findMigrations(this.cwd, this.migrationsFolder)
Expand All @@ -61,9 +65,9 @@ export class Migrator {
async up ({
context,
}: UpOptions) {
await this.prepareUp()

this.context = context
await this.prepareUp({
context,
})

// Files
let count = 0
Expand Down
8 changes: 6 additions & 2 deletions packages/@nodepack/maintenance/src/lib/Maintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ export class Maintenance {
const migrator = new EnvMigrator(cwd, {
migrationsFolder: ENV_MIGRATION_FOLDER,
})
const { files } = await migrator.prepareUp()
const { files } = await migrator.prepareUp({
context,
})
if (files.length) {
// Migrate
await this.shouldCommitState(`[nodepack] before env migration`)
Expand All @@ -219,7 +221,9 @@ export class Maintenance {
const migrator = new DbMigrator(cwd, {
migrationsFolder: DB_MIGRATION_FOLDER,
})
const { files } = await migrator.prepareUp()
const { files } = await migrator.prepareUp({
context,
})
if (files.length) {
// Migrate
await this.shouldCommitState(`[nodepack] before db migration`)
Expand Down

0 comments on commit fbd8880

Please sign in to comment.