run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
Future<int> run() async
{
final config = await loadConfig();
final env = await loadEnv(config);
if (env == null) {
usageException(
'Failed to find the env.\nPlease, specify a valid env in your config.'
);
}
final migrationIdentity = argument('migration identity');
if (migrationIdentity == null) {
usageException('Migration identity is not specified.');
}
final executor = MigrationExecutor(
config: config,
env: env,
passwordProvider: () => getPassword(env.user),
);
try {
await executor.fixMigration(migrationIdentity, delegate: this);
return resultOk;
} on AbortedException {
return resultError;
} on ConnectionException catch (e) {
errorLn('Failed to connect: ${e.message}.');
return resultError;
} on MigrationException catch (e) {
errorCLn('Failed to update migration: ${e.message}.');
return resultError;
} catch (e) {
errorCLn('Failed to update migration: $e.');
return resultError;
}
}