yankee
yankee

Reputation: 40810

Flyway & Applications that allow plugins

I am developing a web application which allows the usage of plugins (Plugins won't just change at runtime. Instead it is more like a customer ordering the software together with plugins A,B,C and the selection will then seldomly change).

Some of the plugins need to add their own tables in the database schema. The core schema is currently managed by flyway which makes migrations so neat and painless that I'd like to continue to do so. The new tables should be created in the same schema so that JDBC-connections can be shared and that plugin tables can have foreign keys to core tables.

However as far as I understood it flyway won't accept multiple flyway instances that reference the same schema. Is that correct? Is there some other way to get the scenario to work?

Upvotes: 0

Views: 68

Answers (1)

Axel Fontaine
Axel Fontaine

Reputation: 35169

The new tables should be created in the same schema so that JDBC-connections can be shared and that plugin tables can have foreign keys to core tables.

This doesn't have to be the case. You could give each plugin its own schema and Flyway instance. You can have foreign keys between schemas and you can refer to multiple schemas through the same connection.

If that is not an option, you can still have a Flyway instance per plugin (each with their own metadata table), just be aware that if they all point to the same schema, calling clean() on any one of them, will wipe the entire schema.

Finally you could also just have one versioning namespace where some migrations are simply not present in certain environments (plugin not installed).

Upvotes: 1

Related Questions