Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

eddumelendez
Copy link
Contributor

See gh-6610

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 11, 2016
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 11, 2016
@philwebb philwebb added this to the 1.5.0 milestone Aug 11, 2016
List<FlywayMigration> migrations = new ArrayList<FlywayMigration>();
for (MigrationInfo info : this.flyway.info().all()) {
migrations.add(new FlywayMigration(info));
public List<List<FlywayMigration>> invoke() {
Copy link
Member

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.

@eddumelendez
Copy link
Contributor Author

Hi @wilkinsona if there any comments in this PR please let me know :)

@wilkinsona
Copy link
Member

Thanks for the updates, @eddumelendez.

I wonder if we could enhance Boot's DataSourcePoolMetadata to provide access to the URL rather than having to establish a connection to the database. Please don't do anything about that just now as it might turn out to be a bad idea. I just wanted to make a note of it here so I didn't forget.

@philwebb philwebb modified the milestones: 1.5.0, 1.5.0 M1 Aug 30, 2016
@snicoll snicoll modified the milestones: 1.5.0, 1.5.0 M1 Aug 31, 2016
@snicoll
Copy link
Member

snicoll commented Oct 10, 2016

I wonder if we could enhance Boot's DataSourcePoolMetadata to provide access to the UR

@wilkinsona I had a look to that and I am not sure we could, really. We would need to change the contract of DataSourcePoolMetadataProvider somehow. Sure we can abstract the url access in the implementation but that's something that would require to open a connection anyway.


public FlywayEndpoint(Flyway flyway) {
public FlywayEndpoint(List<Flyway> flyway) {
Copy link
Member

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();
Copy link
Member

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();
Copy link
Member

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();
Copy link
Member

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() {
Copy link
Member

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()));
Copy link
Member

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.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Oct 10, 2016
@snicoll
Copy link
Member

snicoll commented Nov 3, 2016

@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.

@eddumelendez
Copy link
Contributor Author

Sure @snicoll, I will update the PR. Thanks for feedback

@eddumelendez
Copy link
Contributor Author

@snicoll PR has been updated. Sorry, I just notice you reviewed this 25 days ago... looks like I didn't read that notification 😢

@snicoll
Copy link
Member

snicoll commented Nov 4, 2016

Don't be, it could a different notification from Github or something. I've seen others not replying to that kind of requests.

@eddumelendez eddumelendez removed the status: waiting-for-feedback We need additional information before we can continue label Nov 4, 2016
@snicoll snicoll removed their assignment Dec 1, 2016
@snicoll
Copy link
Member

snicoll commented Dec 22, 2016

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.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Dec 22, 2016
@snicoll snicoll self-assigned this Dec 22, 2016
@snicoll
Copy link
Member

snicoll commented Dec 22, 2016

Actually @bclozel helped me to answer that question.

@snicoll snicoll removed the for: team-attention An issue we'd like other members of the team to review label Dec 22, 2016
snicoll added a commit that referenced this pull request Dec 22, 2016
* pr/6613:
  Polish contribution
  Add support for multiple beans in the Flyway and Liquibase endpoints
@snicoll snicoll closed this in 5d909a9 Dec 22, 2016
@snicoll
Copy link
Member

snicoll commented Dec 22, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants