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

Fixed OSGi metadata table create script loading #758

Merged
merged 1 commit into from May 20, 2014

Conversation

hhamilto
Copy link

This is useful incase the schema table sql migrations aren't available on the user provided classpath, for example in certain osgi configurations.

OSGi Ex:

MyBundle (uses flyway)                                  Flyway
------------------------------------------------------------------------------------------------------------------
Flyway flyway = new Flyway();
// set the ClassLoader so that flyway
// can find the jdbc drivers and the 
// internal migrations
flyway.setClassLoader(
    MyClass.class.getClassLoader());
flyway.setDataSource( ... );
flyway.migrate(); -----------------------------------------> Finds empty db
                                                          Needs to create the schema_version table
                                                          Tries to load classpath resource 
("org/flywaydb/core/internal/dbsupport/" + dbSupport.getDbName() + "/createMetaDataTable.sql")
                                                          ... never resolved because MyBundle doesn't have 
                                                              that resource on its class path.
                                                          But, if we use the class loader OSGi gives flyway
                                                          (eg getClass().getClassLoader()), then flyway can
                                                          successfully load the sql it needs.

Let me know your thoughts, and I'm happy to modify this in any way if you see problems with it, and thanks again for the sharp tool.

…e the schema table sql migrations aren't available on the user provided classpath, for example in certain osgi configurations
axelfontaine pushed a commit that referenced this pull request May 20, 2014
MetaDataTableImpl now uses its own class loader.
@axelfontaine axelfontaine merged commit 54c81a5 into flyway:master May 20, 2014
@axelfontaine axelfontaine changed the title MetaDataTableImpl now uses its own class loader. Fixed OSGi metadata creation script loading May 20, 2014
@axelfontaine axelfontaine changed the title Fixed OSGi metadata creation script loading Fixed OSGi metadata table create script loading May 20, 2014
@axelfontaine
Copy link
Contributor

Good catch! Thanks for the contribution! Merged.

P.S.: I've added you to the hall of of fame page!

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

Successfully merging this pull request may close these issues.

None yet

3 participants