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

Allow custom resolvers #18

Closed
wants to merge 2 commits into from
Closed

Allow custom resolvers #18

wants to merge 2 commits into from

Conversation

jontodd
Copy link

@jontodd jontodd commented Mar 29, 2013

This is a pass at allowing for custom MigrationResolvers as discussed in this ticket:
http://code.google.com/p/flyway/issues/detail?id=469

With this these changes, creating the command line tool which uses both the default resolvers and a custom resolver looks like this:

            Flyway flyway = new Flyway();
            flyway.configure(properties);

            //
            // Resolvers
            //

            Locations sqlMigrationLocations = getMigrationLocationsForKey(properties, "flyway.locations");
            Locations metadataMigrationLocations = getMigrationLocationsForKey(properties, "app_metadata_locations");

            Collection<MigrationResolver> resolvers = new LinkedList<MigrationResolver>();

            // Default migration resolvers
            MigrationResolver defaultMigrationResolver = Flyway.newDefaultMigrationResolver(
                    sqlMigrationLocations, flyway.getEncoding(), flyway.getSqlMigrationPrefix(),
                    flyway.getSqlMigrationSuffix(), flyway.getPlaceholders(), flyway.getPlaceholderPrefix(), flyway.getPlaceholderSuffix());
            resolvers.add(defaultMigrationResolver);


            // Metadata migration resolvers
            for (Location location : metadataMigrationLocations.getLocations()) {
                MetadataMigrationResolver metadataMigrationResolver = new AppMetadataMigrationResolver(location, METADATA_MIGRATION_PREFIX, METADATA_MIGRATION_SUFFIX);
                resolvers.add(metadataMigrationResolver);
            }

            flyway.setMigrationResolvers(resolvers);


            executeOperation(flyway, operation);

Additional details are in the individual commit messages.

Look forward to your feedback!

There are no functional changes in this commit, the goal is just to decouple the logic which knows how to create the default MigrationResolver used in Flyway from the CompositeMigrationResolver so that the CompositeMigrationResolver can support creation with an arbitrary collection of MigrationResolvers.
@axelfontaine
Copy link
Contributor

Hi Jon,

thanks for your patch. I currently do not want to make this part of the API public.

Cheers
Axel

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

2 participants