db-migrator

24 views
Skip to first unread message

a90...@gmail.com

unread,
Mar 30, 2015, 8:28:54 AM3/30/15
to activejd...@googlegroups.com
Hello,
Can I use db-migrator at the executing phase but not at the build phase?

Igor Polevoy

unread,
Mar 30, 2015, 11:56:21 AM3/30/15
to activejd...@googlegroups.com
db-migrator ... migrates the database. You can use it at any phase, as long as code you  run after will find the right  schema in the DB 

a90...@gmail.com

unread,
Mar 30, 2015, 1:41:39 PM3/30/15
to activejd...@googlegroups.com

I’d like to use db-migrator to update my application on another computer. For example: java –jar migrate.jar

My code is:

Migration migration = new Migration(versionFile, file);
DbUtils.openConnection(driver, url, username, password);
migration
.migrate("UTF-8");
DbUtils.closeConnection();

 

Migration executes even when there is “version” field  = versionFile at «schema_version» table.

 

Do you speak Russian?


Я хотел бы использовать механизм миграции для обновления приложения на другом компьютере, путем запуска консольного приложения, например:  java –jar migrate.jar

В приложении, я использую

Migration migration = new Migration(versionFile, file);
DbUtils.openConnection(driver, url, username, password);
migration
.migrate("UTF-8");
DbUtils.closeConnection();


Однако миграция выполняется всегда, даже тогда, когда в таблице schema_version поле version = versionFile

a90...@gmail.com

unread,
Mar 30, 2015, 2:32:00 PM3/30/15
to activejd...@googlegroups.com
Solution:      
DbUtils.openConnection(driver, url, username, password);
try {        
   
new MigrationManager(path).migrate(new SystemStreamLog() , "UTF-8");
} catch (Exception e) {
    e
.printStackTrace();
}
DbUtils.closeConnection();


Igor Polevoy

unread,
Mar 31, 2015, 2:03:23 AM3/31/15
to activejd...@googlegroups.com
Hi, I do speak Russian, but cannot type:( besides, other people can benefit from we keep this in English.

While you can use the API from migrator directly, I suggest you use a Maven plugin and configure the property file for different environments, including 

We do this all the time, when migrating production databases. 

tx

a90...@gmail.com

unread,
Mar 31, 2015, 1:47:41 PM3/31/15
to activejd...@googlegroups.com
Thank you for your response.
Method of property file configuration is not suitable for me, because it is impossible to connect  the corporate DB. And it is not correct to provide the source code to users as they can not  build application on their own.

Igor Polevoy

unread,
Mar 31, 2015, 1:56:23 PM3/31/15
to activejd...@googlegroups.com
if you can connect the way  you do, than you should be able to connect with a property file. 
Not sure about your other comment. I directed  you to documentation, not source code. 
Reply all
Reply to author
Forward
0 new messages