Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8980709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:09:17+00:00 2026-06-15T20:09:17+00:00

I have created two different instances of Flyway in 2 different projects in my

  • 0

I have created two different instances of Flyway in 2 different projects in my eclipse workspace.

They are pointing to different data sources/2 diff databases and also have separate src.main.resources.db.migration packages. Each package contains different sql files for the respective databases.

When I start my application, Flyway is identifying scripts from one project only (project initialized first) and executing the scripts from this project to the other DB also.

Is it possible for Flyway to update 2 databases simultaneously?


Thanks for the reply. But could you please explain how this can be implemented in Java Code.
For eg: Curretnly I am using the following way…

            Flyway flyway = new Flyway();               
            InitialContext ictx = new InitialContext();
            DataSource dataSource = (DataSource) ictx.lookup("DS-name");
            flyway.setDataSource(dataSource);
            flyway.setLocations("main.resources.db.migration");//location under first project
                flyway.migrate();

                 Flyway flywaygen =  new Flyway;

            InitialContext ictx = new InitialContext();
            DataSource dataSource = (DataSource) ictx.lookup("DS-name");
            flywaygen.setDataSource(dataSource);
            flywaygen.setLocations("main.resources.emlogis.migration");//location                       under second project
                flywaygen.migrate();

The issue is that flywaygen is also looking at the first project location. So if in the first location 3 sql scripts are added and 2 scripts in the second one, the second flyway instance says Migration 3 completed. So flywaygen is also pointing at main.resources.db.migration instead of main.resources.emlogis.migration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:09:18+00:00Added an answer on June 15, 2026 at 8:09 pm

    Define a second flyway bean. Then add to both flyway beans a different SqlMigrationPrefix property and name your migration scripts accordingly.

    For example

    <bean class="com.googlecode.flyway.core.Flyway" init-method="migrate">
       <property name="dataSource" ref="dataSource1" />
       <property name="sqlMigrationPrefix" value="DB1_" />
    </bean>
    <bean class="com.googlecode.flyway.core.Flyway" init-method="migrate">
       <property name="dataSource" ref="dataSource2" />
       <property name="sqlMigrationPrefix" value="DB2_" />
    </bean>
    

    Your migration scripts have to follow this naming scheme:

    DB1_1.0__initial_setup.sql
    DB1_1.1__new_column.sql
    
    DB2_1.0__initial_setup.sql
    DB2_1.1__new_column.sql
    

    EDIT – configuration by code:

    In your code you are having two Flyway instances. This instances are equivalent to the definition as a spring bean. So you can call the following to achieve the same:

    flyway.setSqlMigrationPrefix("DB1_");
    flywaygen.setSqlMigrationPrefix("DB2_");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server 2008 R2. I have created two different databases Master
I have created Guice binding annotations that allow me to bind two different instances
I have two list of different objects : List<Report> List<Newsletter> each having a 'created
I have two different .Net projects, hosted on github. I would like to create
I have two tables in two different SQL Server databases on different servers. Each
I have a requirement to create two different maps in C++. The Key is
I have created two imageViews promatically as shown below: public void createImageViews(Integer count){ ImageView[]
I have created two WindowSurface (WPF), and I want to navigate betwen them. I've
I have created two tables & inserted values as shown below . Table 1
I have created two Pages Page1.xaml and Page2.xaml in windows8 metro apps. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.