tlberglund/gradle-liquibase-plugin

No way to specify connection between database and changelog

Closed this issue · 8 comments

We use several different databases in each environment of our system. On a typical deploy, we thus want to run a specific changelog for each database. I can see no way to achieve this, as every specified changelog is applied to each database.

In other words, I want to say "run this particular changelog on this particular database."

Have you looked at Liquibase contextes? You can assign a context to a changeset, then run run Liquibase with the --context option to tell it in what context it is currently running.

I'm not certain that --context works in the plugin at the moment, but it should be working when we release 1.0.0, which I'm hoping to be able to do in the next week or so.

Thanks for your suggestion, stevesaliman. However, I don't believe it really solves our problem. We already use contexts to manage the difference between different environments, and if we hare to use it different databases in the same environment as well, I think it will quickly become unwieldy. Five environments times three databases makes for fifteen contexts.

I think I understand what you're getting at. I'm seeing something like the following:

You have several environments, such as Development, QA, User Acceptance, Production, etc. When you deploy to an environment, you want the update task to run an application changelog to the application database for the environment and a security changelog to the security system database for the same environment.

Is that the basic idea?

I'm looking at overhauling the way the Liquibase plugin is configured, so this is a good time to make sure the plugin handles your use case.

Yes, you have nailed the description of what we are doing. We would therefore have great use of a more flexible configuration.

A possible workaround when using the current version of the plugin could be to put the configuration of different databases in different sub projects of our build, but other reason makes such an approach cumbersome for us.

Let me know if I can be of any help in testing a new way of configuring the plugin.

I've pushed the latest snapshot to github. It hasn't been published to any Maven repository, but you can build the snapshot and try it out on your project. You would also need to check out and build the groovy-liquibase project.

Quite a lot has changed since the last release of this plugin, so you'll definitely want to take a look at the README file and try it all out in a database you don't care about.

With luck, I'll have the work on this plugin wrapped up in the next couple of weeks.

The new way of configuring the databases seems perfect for our needs. However, I am running into some trouble when trying out the snapshot. I have built the snapshot and made it available in my build file through "apply plugin: 'liquibase'". I have then configured the liquibase block as follows:

    liquibase {
        activities {
            main {
                changeLogFile 'changelogs.groovy'
                url 'jdbc:mysql://${deployHost}/${dbName}'
                username project.dbAdminUser
                password project.dbAdminPassword
            }
        }
    }

However, when I run "gradle generateChangelog" (or any other liquibase task), I get the following error:

Execution failed for task ':feedreader:generateChangelog'.
> No signature of method: com.augusttechgroup.gradle.liquibase.LiquibaseTask_Decorated.runLiquibase() is applicable for argument types: (com.augusttechgroup.gradle.liquibase.Activity) values: [com.augusttechgroup.gradle.liquibase.Activity@28d1edbb]

I am surely doing something wrong, but I can't figure out what is the problem.

This has been fixed, thanks to haraldradi.

You weren't doing anything wrong, but it seems that newer versions of Gradle have an issue with the private helper method I was using to actually invoke Liquibase.

Does it work for you now?

Yes, now it works very well. Thanks for your great work!