-
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
When using Hibernate ORM multitenancy by schema, Flyway scripts only run in the default schema #15602
Comments
@iddacosta Thanks for your report. Unfortunately, I suspect the problems you've been experiencing are caused by invalid configuration; The resulting, fixed reproducer (which no longer fails) can be found here: Problems in the reproducerSpaces in configuration valuesComma-separated configuration values must be separated by commas, not by commas + space. So you should fix this: flyway:
migrate-at-start: true
baseline-on-migrate: true
baseline-version: 1.0.0
create-schemas: true
clean-at-start: true
- schemas: maripa, bicas, rhino
+ schemas: maripa,bicas,rhino
- locations: db/migration/maripa, db/migration/bicas, db/migration/rhino
+ locations: db/migration/maripa,db/migration/bicas,db/migration/rhino Incomplete SQL scriptsThe SQL scripts include a reference to table Invalid datasource referenceYour configuration references a datasource that doesn't exist:
The name I removed the line Duplicate SQL scripts for versionApparently, Flyway expects exactly one SQL script for each version, so you layout with one script per schema doesn't work. Just merge your scripts (adding the schema qualifier before references, e.g. Duplicate REST endpointsYou have two different REST endpoints for the same path ( Give a different name to each endpoint: @GetMapping
public ResponseEntity<List<UserDTO>> findAll() {
return ResponseEntity.ok().body(userService.findAllUsers());
}
- @GetMapping
+ @GetMapping("/by-username/")
public ResponseEntity<UserDTO> findByUsername(@RequestParam("nome") final String nome) {
try {
final UserDTO userDTO = userService.findByUsername(nome);
return ResponseEntity.ok().body(userDTO);
} catch (UserNotFoundException exception) {
return handleException(exception);
}
} Using default-schema with schema-based multi-tenancyWhatever schema your tenant ID select, this bit will override it:
So it's not a good idea to set it along with schema-based multi-tenancy. Remove this from your configuration. "user" table name"user" is a reserved keyword in postgresql, and attempting to use it in SQL queries will lead to strange results. You really should escape it:
ConclusionStrictly speaking, it seems problems are in the reproducer, not in Quarkus. So I will close this issue as invalid. If you think otherwise, feel free to reopen this issue or to open another one. However, there are usability problems, and I will open additional issues about those:
|
Describe the bug
Multitenant BUG
Flyway BUG
Expected behavior
Schema change dynamic with hibernate in query
Flyway run scripts in all schemas
Actual behavior
Queries only run in default schema
To Reproduce
Steps to reproduce the behavior:
rhino.zip
The text was updated successfully, but these errors were encountered: