-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow db-migrate without version
Signed-off-by: David Goss <david@davidgoss.co>
- Loading branch information
1 parent
d9ec368
commit 6f21abe
Showing
5 changed files
with
47 additions
and
123 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2018-2022 contributors to the Marquez project | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package marquez.cli; | ||
|
||
import io.dropwizard.cli.ConfiguredCommand; | ||
import io.dropwizard.db.DataSourceFactory; | ||
import io.dropwizard.db.ManagedDataSource; | ||
import io.dropwizard.setup.Bootstrap; | ||
import lombok.NonNull; | ||
import lombok.extern.slf4j.Slf4j; | ||
import marquez.MarquezConfig; | ||
import marquez.db.DbMigration; | ||
import net.sourceforge.argparse4j.inf.Namespace; | ||
|
||
/** | ||
* A command to manually run database migrations. This command to be used to run migrations | ||
* decoupled from application deployment. | ||
*/ | ||
@Slf4j | ||
public class DbMigrateCommand extends ConfiguredCommand<MarquezConfig> { | ||
|
||
public DbMigrateCommand() { | ||
super("db-migrate", "A command to manually run database migrations."); | ||
} | ||
|
||
@Override | ||
protected void run( | ||
@NonNull Bootstrap<MarquezConfig> bootstrap, | ||
@NonNull Namespace namespace, | ||
@NonNull MarquezConfig configuration) | ||
throws Exception { | ||
|
||
final DataSourceFactory sourceFactory = configuration.getDataSourceFactory(); | ||
final ManagedDataSource source = | ||
sourceFactory.build(bootstrap.getMetricRegistry(), "MarquezApp-source"); | ||
|
||
DbMigration.migrateDbOrError(configuration.getFlywayFactory(), source, true); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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