How to configure multiple Databases #3537
Closed
codejanovic
started this conversation in
General
Replies: 2 comments
-
So with the help from others I found out how to simply manually control the migrations to process: var newsletterDatabaseConfig = Config.forPath("datasource.db");
var migrationConfig = new MigrationConfig();
migrationConfig.setDbUsername(newsletterDatabaseConfig.get("username"));
migrationConfig.setDbPassword(newsletterDatabaseConfig.get("password"));
migrationConfig.setDbUrl(newsletterDatabaseConfig.get("url"));
migrationConfig.setDbSchema("public");
var migrationRunner = new MigrationRunner(migrationConfig);
migrationRunner.run(); and turning off automatic migration ebean.migration.run= false But i could not yet figure out how to tell DbMigration to only migrate a single database instead of all of them. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Okay, looks like I found out how to specify a certain database to run db migrations for: public class GenerateDbMigration {
public static void main(String[] args) throws IOException {
DbMigration dbMigration = DbMigration.create();
dbMigration.setPlatform(Platform.POSTGRES);
dbMigration.setServer(DB.getDefault()); <<-------
dbMigration.generateMigration();
}
} So now it looks like everything works as expected now! Maybe this will help some other folks in the future |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
i am struggling to setup ebean with multiple Databases, where only for one of those Databases should be actively migrated by ebean. All other databases should not be migrated and are only there for manual querying in readonly mode.
I thought the migrations are only run for/against the "default" database, but it runs for every database.
So thats how my
application.properties
look like:Sadly, running the migration creation will generate Migrations for all created entities, regardless of which Database they are from.
Is there something i am missing or is ebean designed to just run migrations against every database that is configured without any optout capability ?
Cheers,
Aleks
Beta Was this translation helpful? Give feedback.
All reactions