mybatis runtime migrations database provider flavor

10 views
Skip to first unread message

yaog

unread,
Jun 30, 2019, 9:51:30 AM6/30/19
to mybatis-user
When using mybatis migrations what's the best practice if I need to support multiple databases using the same application version?
Regular queries are supported by using databaseProviderId. What would be the migrations equivalent?

Iwao AVE!

unread,
Jul 3, 2019, 5:46:14 AM7/3/19
to mybatis-user
Hi,

If it's just a simple difference like column type (e.g. datetime2 for SQL server, datetime for MySQL), you can declare a variable in the environment files.

# mssql.properties
datetimeColumnType=DATETIME2

# mysql.properties
dateteimeColumnType=DATETIME

and reference it in migration script.

create table (id int, dt ${datetimeColumnType});

In case you need to create a separate file (e.g. 001_example_mysql.sql, 001_example_mssql.sql) or directory (e.g. scripts_mysql, scripts_mssql) for each database, custom MigrationLoader might help.

If these don't meet your needs, please post more info.

Regards,
Iwao


On Sun, Jun 30, 2019 at 10:51 PM yaog <yair...@gmail.com> wrote:
When using mybatis migrations what's the best practice if I need to support multiple databases using the same application version?
Regular queries are supported by using databaseProviderId. What would be the migrations equivalent?

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/c503f4a4-a64f-445c-8e07-2be871fba575%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages