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
Add support for multiple beans in the Flyway and Liquibase endpoints #6613
Conversation
List<FlywayMigration> migrations = new ArrayList<FlywayMigration>(); | ||
for (MigrationInfo info : this.flyway.info().all()) { | ||
migrations.add(new FlywayMigration(info)); | ||
public List<List<FlywayMigration>> invoke() { |
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.
Changing to List<List<FlywayMigration>>
breaks backwards compatibility without any benefit. I think we should either keep the old format, or change to a Map<String, List> where the string somehow indicates which DataSource the migrations were run against. The JDBC URL of the DB would be ideal, but I'm not sure we can get that.
Hi @wilkinsona if there any comments in this PR please let me know :) |
Thanks for the updates, @eddumelendez. I wonder if we could enhance Boot's |
@wilkinsona I had a look to that and I am not sure we could, really. We would need to change the contract of |
|
||
public FlywayEndpoint(Flyway flyway) { | ||
public FlywayEndpoint(List<Flyway> flyway) { |
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.
You're breaking backward compat there. Can you please add the constructor with a single resource back and just call the other one with Collections.singletonList
?
Map<String, List<FlywayMigration>> migrations = new HashMap<String, List<FlywayMigration>>(); | ||
for (Flyway flyway : this.flyway) { | ||
try { | ||
DatabaseMetaData metaData = flyway.getDataSource().getConnection().getMetaData(); |
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.
You need to close the Connection
.
} | ||
finally { | ||
connection.close(); |
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.
ditto...
return service.queryDatabaseChangeLogTable(database); | ||
DatabaseMetaData metaData = liquibase.getDataSource().getConnection().getMetaData(); | ||
try { | ||
DatabaseFactory factory = DatabaseFactory.getInstance(); |
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 you need to initialize the factory every time there.
@@ -207,6 +212,20 @@ public void testFlywayEndpoint() { | |||
} | |||
|
|||
@Test | |||
public void testTwoFlywayEndpoint() { |
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.
typo, Endpoints
@@ -153,12 +155,12 @@ public ConditionEvaluationReport conditionEvaluationReport( | |||
|
|||
@Bean | |||
public FlywayEndpoint flyway() { | |||
return new FlywayEndpoint(new Flyway()); | |||
return new FlywayEndpoint(Arrays.asList(new Flyway())); |
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 breaking backward compat means you don't need to change this no more.
@eddumelendez did you have a chance to review my comments? If you don't have time, let us know and we'll rework the PR. |
Sure @snicoll, I will update the PR. Thanks for feedback |
@snicoll PR has been updated. Sorry, I just notice you reviewed this 25 days ago... looks like I didn't read that notification 😢 |
Don't be, it could a different notification from Github or something. I've seen others not replying to that kind of requests. |
OK, that looks good except one thing I am not sure. The key is the URL of the database, so you end up with something like this: {
"jdbc:h2:mem:testdb": [
{
"type": "SQL",
"checksum": 710039845,
"version": "1",
"description": "init",
"script": "V1__init.sql",
"state": "SUCCESS",
"installedOn": 1482400309894,
"executionTime": 6
}
]
} I see no other way to generate a sensible id for the datasource but perhaps the team has a better idea. |
Actually @bclozel helped me to answer that question. |
* pr/6613: Polish contribution Add support for multiple beans in the Flyway and Liquibase endpoints
Thank you @eddumelendez - Exposing the URL of the datasource is something we're not keen doing (the health endpoint doesn't do that). Besides, it's quite hard to "index" data based on the url. For that stuff we usually use the name of the bean. That's what I've done in 5d909a9 |
See gh-6610