mybatis runtime migrations database provider flavor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mybatis runtime migrations database provider flavor

yaog
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/c503f4a4-a64f-445c-8e07-2be871fba575%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis runtime migrations database provider flavor

Iwao AVE!
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 <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/c503f4a4-a64f-445c-8e07-2be871fba575%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CA%2Buep2TsuHM%3DynvBdHnVx9cKZSDpbKbkP7wEZ8UThbkTYF%3D5XQ%40mail.gmail.com.