-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update migrations descriptions, migrations list supports json (#5222)
* update migrations descriptions, migrations list supports json * use waitForOpen instead of a try/catch for DB
- Loading branch information
Showing
4 changed files
with
46 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,39 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
import { NodeUtils } from '@ironfish/sdk' | ||
import { IronfishCommand } from '../../command' | ||
import { JsonFlags } from '../../flags' | ||
import * as ui from '../../ui' | ||
|
||
export class StatusCommand extends IronfishCommand { | ||
static description = `list data migrations` | ||
static description = `list data migrations and their status` | ||
static enableJsonFlag = true | ||
|
||
async start(): Promise<void> { | ||
static flags = { | ||
...JsonFlags, | ||
} | ||
|
||
async start(): Promise<unknown> { | ||
await this.parse(StatusCommand) | ||
|
||
const node = await this.sdk.node() | ||
await node.migrator.check() | ||
|
||
// Verify the DB is in a state to be opened by the migrator | ||
await NodeUtils.waitForOpen(node) | ||
await node.closeDB() | ||
|
||
const migrationsStatus = await node.migrator.status() | ||
|
||
const displayData: Record<string, string> = {} | ||
for (const { name, applied } of migrationsStatus.migrations) { | ||
displayData[name] = applied ? 'APPLIED' : 'WAITING' | ||
} | ||
|
||
this.log(ui.card(displayData)) | ||
|
||
this.log(`\nYou have ${migrationsStatus.unapplied} unapplied migrations.`) | ||
|
||
return migrationsStatus | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters