English 中文(简体)
Is flyway database agnostic in its support for multiple databases?
原标题:
  • 时间:2011-09-05 15:05:41
  •  标签:
  • flyway

Is Flyway suitable for implementation in an application that will support multiple databases?

We don t know what our customers are using - could be either MySQL, Postgres or Oracle. Can we still use Flyway to migrate the database for new versions of the application?

最佳回答

if your question is: does Flyway provide a DDL abstraction layer across the databases it supports, the answer is no.

This was a conscious design decision, to make sure the full power of the underlying database is available and not just the smallest common denominator supported by the migration tool.

For your use case, you could either provide different migration scripts for the different databases. They should be very similar though.

If you do not wish to potentially duplicate the migration scripts and can live with the smallest common denominator approach, have a look at LiquiBase which might be a better fit for your usecase (if you can live with the XML)

问题回答

You could use jOOQ s parsing connection, which wraps your target JDBC connection and is capable of translating your input DDL to any target dialect (if it s not too fancy and vendor specific). Flyway wouldn t be aware of this translating JDBC proxy, and wouldn t have to be. The online version of the SQL translator can be seen here. For example, if your input SQL is a MySQL specific:

create table t (i int primary key auto_increment);

The output could be:

-- Oracle
create table T (
  I number(10) generated by default as identity(start with 1) not null,
  primary key (I)
);

-- SQL Server
create table T (
  I int identity(1, 1) not null,
  primary key (I)
)

-- PostgreSQL
create table T (
  I int generated by default as identity not null,
  primary key (I)
)

-- PostgreSQL 9.4
create table T (
  I serial4 not null,
  primary key (I)
)

Disclaimer: I work for the company behind jOOQ.





相关问题
Flyway, Postgresql, Unable to acquire Flyway advisory lock

We had a transaction that updates 2000000 rows in a postgresql 10 database using flyway (v6). It failed with Unable to acquire Flyway advisory lock . 2000000 records is not that big and it is 1 ...

Pre- and Post-migration scripts for Flyway

I am looking for a way to execute a hook script before and after migration. I have a bunch of views and stored procedures and would like the process to be: Drop all views and stored procedures. Run ...

Flyway output to SQL File

Is it possible to output the db migration to an SQL file instead of directly invoking database changes in flyway?

Flyway migration during ear deployment

We would love it if Flyway could migrate our database during deployment of an .ear artifact (JBoss 4.2). It should abort if anything goes wrong. Flyway with mvn flyway:migrate works, but for ...

Flyway: Support for older DB s

I m currently trying to set up some simple migration scripts for our databases. I was checking flyway, which seems to be simple enough for what I need. My problem is that, for Postgres, only version 9 ...

热门标签