-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flyway multitenant extension #43892
base: main
Are you sure you want to change the base?
Flyway multitenant extension #43892
Conversation
77c0ef9
to
9b18495
Compare
cc @geoand |
9b18495
to
7fbb1cc
Compare
This comment has been minimized.
This comment has been minimized.
🎊 PR Preview b46c8ef has been successfully built and deployed to https://quarkus-pr-main-43892-preview.surge.sh/version/main/guides/
|
This comment has been minimized.
This comment has been minimized.
Nice! I'll have a close look in the following days, but I see that CI is not happy.
|
7fbb1cc
to
d3e33bb
Compare
4604dea
to
8758112
Compare
This comment has been minimized.
This comment has been minimized.
8758112
to
9a47185
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9a47185
to
5c8b85a
Compare
Status for workflow
|
|
||
import java.util.List; | ||
|
||
public interface FlywayTenantSupport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about the naming of this one
Status for workflow
|
Quarkus Extension: Flyway Support for Hibernate Multitenancy
Overview
This pull request introduces a new Quarkus extension, quarkus-flyway-multitenant, which enables Flyway integration with Hibernate in multitenant schema-based mode.
Currently, Hibernate handles schema-based multitenancy effectively, but there is no built-in way to manage schema creation or apply migrations lazily for specific tenants. This extension bridges that gap, allowing users to manage migrations in multitenancy scenarios with greater flexibility.
Key Features
Flyway Schema Migration per Tenant:
The extension provides the
@FlywayPersistenceUnit
annotation, allowing developers to inject Flyway objects for individual tenants or persistence units.Automatic Migration at Startup:
Support for specifying tenants to be migrated at application startup through the FlywayTenantSupport interface when the quarkus.flyway.multitenant.migrate-at-start property is enabled.
On-demand Migration:
Support for lazy migration when a tenant is resolved using a custom FlywayTenantResolverDecorator that runs migrations automatically for the resolved tenant.
This is not included in this PR since the user might want to customize the decorator logic, add caching, but an example implementation is provided in the doc. I am planning to provide a customizable implementation in a subsequent PR.
How to Use
Add the quarkus-flyway-multitenant extension to your project:
Use the
@FlywayPersistenceUnit
annotation to inject Flyway instances for specific tenants or persistence units.To automatically run migrations on startup for a set of tenants, implement the FlywayTenantSupport interface.
For automatic tenant-specific migrations during tenant resolution, decorate your TenantResolver.
related to #37080