-
Notifications
You must be signed in to change notification settings - Fork 160
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
Implement multi-schema support #727
base: main
Are you sure you want to change the base?
Implement multi-schema support #727
Conversation
src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java
Outdated
Show resolved
Hide resolved
7effe3b
to
0385016
Compare
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.
Approved.
Besides the minor comment I posted this looks good to me. Thank you, @philipp-kleber-avelios for contributing with this PR.
Daniel.
src/main/java/liquibase/ext/hibernate/snapshot/SequenceSnapshotGenerator.java
Outdated
Show resolved
Hide resolved
21227fc
to
6d8764b
Compare
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.
Thanks for the improvement @philipp-kleber-avelios !
@tati-qalified if you need any ideas on how to test it please let me know.
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.
Thank you @philipp-kleber-avelios for your contribution!
I was wondering if the entities for the test could be narrowed down, I don't think it's necessary to create 13 classes just for one test case.
@@ -34,6 +34,10 @@ protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) thro | |||
Schema schema = (Schema) foundObject; | |||
HibernateDatabase database = (HibernateDatabase) snapshot.getDatabase(); | |||
for (org.hibernate.boot.model.relational.Namespace namespace : database.getMetadata().getDatabase().getNamespaces()) { | |||
if (!schemaMatchesNamespace(schema, namespace)) { | |||
continue; |
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.
@philipp-kleber-avelios in this piece of code it's checking if the schema doesn't match the namespace, but then it does nothing either way. Did you mean to add something else inside the if block? If not, it should be removed
Table table = new Table().setName(hibernateTable.getName()); | ||
Scope.getCurrentScope().getLog(getClass()).info("Found table " + table.getName()); | ||
if (!schemaMatchesTable(example, hibernateTable)) { | ||
Scope.getCurrentScope().getLog(getClass()).info("Skipping table " + hibernateTable.getName() + " for schema " + example.getSchema().getName() + ", because it is part of another one."); |
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.
The last part because it is part of another one
isn't too clear, I'd change it to because it belongs to a different schema.
These changes are an initial experiment to resolve issue #248, by allowing multiple schemas during the snapshot.
I added a new test
HibernateMultiSchemaTest.java
, which currently only checks the exit code of such a multi-schemadiffChangelog
command.If somebody could review the code and maybe give their input if the changes are sufficient or if additional ones are required, that would be great, thanks!.