Issue 249 in flyway: find way to support multiple modules

651 views
Skip to first unread message

fly...@googlecode.com

unread,
Apr 24, 2012, 8:25:12 PM4/24/12
to flywa...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 249 by xyz20...@gmail.com: find way to support multiple modules
http://code.google.com/p/flyway/issues/detail?id=249

If my project is merged by multiple modules, such as user module,
organization module, authority modules. All of them has its own flyway to
manage database schema. If I want to put them together, I meet a problem
that I have to rewrite their flyway sql. If flyway could support multiple
schema, like add a column named 'module' to meta table, would be a good
news to me. Any advices will be appreciated. Thank you.

fly...@googlecode.com

unread,
Apr 27, 2012, 8:30:44 AM4/27/12
to flywa...@googlegroups.com

Comment #1 on issue 249 by axel.fontai...@gmail.com: find way to
Hi,

Does this FAQ entry solve your problem? ->
http://code.google.com/p/flyway/wiki/FAQ#Does_Flyway_support_multiple_schemas?

Let me know if it does or not and if you need additional info.

Cheers,
Axel

fly...@googlecode.com

unread,
Apr 27, 2012, 7:08:12 PM4/27/12
to flywa...@googlegroups.com

Comment #2 on issue 249 by xyz20...@gmail.com: find way to support multiple
modules
http://code.google.com/p/flyway/issues/detail?id=249

Thank you for reply.
FAQ shows a way to manage multiple schema, but we want to create only one
schema. This schema may contains some modules, these modules should be
managed separately.
eg:
organization : 1.0.0 -> 1.1.0 -> 1.2.0
user management : 1.0.0 -> 2.0.0
authentication : 1.0.0 -> 1.0.1
That means that we have an application with multiple modules, each module
has its own version control. Than we could upgrade one of these modules
without know the version of other modules.

Now flyway could manage just one version, if I want to put these modules
together, I must put sql files together, It is hard to seperate sql by
module. when I want to reuse one of these modules, I had to re-write its
sql files again and again.

So is there any plan for supporting this feature? I remembered that the
meta table of dbdeploy had a column named DELTA_SET could tell us which
module is used.

Thank you very much.

fly...@googlecode.com

unread,
Apr 29, 2012, 10:01:54 PM4/29/12
to flywa...@googlegroups.com

Comment #3 on issue 249 by axel.fontai...@gmail.com: find way to
OK, I understand you now.

I believe the flyway.table could be what you are looking for.

You could have one Flyway instance per module and configure each to have a
different table.

Ex.:
Organization -> flyway.table=organization_schema_history
Authentication -> flyway.table=authentication_schema_history
User Management -> ...

The only thing to watch out for would be clean(), which would clean the
entire schema. This should in practice not be such a big deal, as it is
only really used in DEV anyway.

Does this solution work for you?

Cheers,
Axel

fly...@googlecode.com

unread,
Jul 3, 2012, 4:26:57 AM7/3/12
to flywa...@googlegroups.com

Comment #4 on issue 249 by xyz20...@gmail.com: find way to support multiple
modules
http://code.google.com/p/flyway/issues/detail?id=249

Thank you Axel, I achieved with anttask, since maven-plugin is hard to
execute difference configuration in an goal.

my pom.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.webapp</groupId>
<artifactId>flyway</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>flyway</name>
<description>flyway</description>

<build>
<defaultGoal>antrun:run</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<configuration>
<target>
<path id="project.classpath">
<path refid="maven.plugin.classpath"/>
<pathelement location="."/>
</path>

<taskdef name="migrate"
classname="com.googlecode.flyway.ant.MigrateTask" />
<taskdef name="clean" classname="com.googlecode.flyway.ant.CleanTask" />
<taskdef name="init" classname="com.googlecode.flyway.ant.InitTask" />

<clean driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:db;shutdown=true"
user="sa"
password="" />

<init driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:db;shutdown=true"
user="sa"
password=""
table="SCHEMA_VERSION_AUTH" />

<init driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:db;shutdown=true"
user="sa"
password=""
table="SCHEMA_VERSION_JILL" />

<migrate driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:db;shutdown=true"
user="sa"
password=""
classpathref="project.classpath"
baseDir="db/auth"
table="SCHEMA_VERSION_AUTH" />

<migrate driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:file:db;shutdown=true"
user="sa"
password=""
classpathref="project.classpath"
baseDir="db/jill"
table="SCHEMA_VERSION_JILL" />
</target>
</configuration>
<dependencies>
<dependency>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-ant</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<properties>
<java.version>1.5</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hsqldb.version>2.2.8</hsqldb.version>
<flyway.version>1.6.1</flyway.version>
</properties>

</project>


fly...@googlecode.com

unread,
Jul 3, 2012, 6:37:34 AM7/3/12
to flywa...@googlegroups.com
Updates:
Status: WontFix

Comment #5 on issue 249 by axel.fontai...@gmail.com: find way to
OK, I'm glad you solved it. Maven profiles containing executions with
different ids could have also worked for you.

Cheers
Axel

fly...@googlecode.com

unread,
Jul 4, 2012, 9:17:46 PM7/4/12
to flywa...@googlegroups.com

Comment #6 on issue 249 by xyz20...@gmail.com: find way to support multiple
modules
http://code.google.com/p/flyway/issues/detail?id=249

I created multiple profiles with difference ids, but I cannot exexute them
at one time. I have to execute them in separate console, that is too slow,
so I use ant task instead.
Maybe maven plugin could support execute difference table at one time?
:)


fly...@googlecode.com

unread,
Mar 14, 2014, 12:13:18 PM3/14/14
to flywa...@googlegroups.com

Comment #7 on issue 249 by julien.m...@gmail.com: find way to support
multiple modules
http://code.google.com/p/flyway/issues/detail?id=249

Sorry to up this topic, but i've found an another solution, this can
interesst many people:

[code]

<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1100-jdbc41</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>db_core</id>
<phase>compile</phase>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<url>jdbc:postgresql:test</url>
<user>postgres</user>
<password>manager</password>
<schemas>
<schema>schema1</schema>
</schemas>
<locations>
<location>db/schema1</location>
</locations>
</configuration>
</execution>
<execution>
<id>db_api</id>
<phase>compile</phase>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<url>jdbc:postgresql:test</url>
<user>postgres</user>
<password>manager</password>
<schemas>
<schema>schema2</schema>
</schemas>
<locations>
<location>db/schema2</location>
</locations>
</configuration>
</execution>
<execution>
<id>db_eve</id>
<phase>compile</phase>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<url>jdbc:postgresql:test</url>
<user>postgres</user>
<password>manager</password>
<schemas>
<schema>schema3</schema>
</schemas>
<locations>
<location>db/schema3</location>
</locations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<versionRange>[1.2,)</versionRange>
<goals>
<goal>migrate</goal>
</goals>
</pluginExecutionFilter>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
[/code]

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

fly...@googlecode.com

unread,
Mar 14, 2014, 12:15:49 PM3/14/14
to flywa...@googlegroups.com

Comment #8 on issue 249 by julien.m...@gmail.com: find way to support
multiple modules
http://code.google.com/p/flyway/issues/detail?id=249

Sorry to up this topic, but i've found another solution to solve this
problem (in my case i've 3 different schemas, but you can do the same with
one schema and 3 different tables)
Reply all
Reply to author
Forward
0 new messages