Flyway

Flyway: non-empty schema without metadata table

别等时光非礼了梦想. 提交于 2019-11-30 00:14:52
问题 Found non-empty schema "public" without metadata table! Use init() or set initOnMigrate to true to initialize the metadata table. I'm using Postgres 9.2 with Postgis 2.0. This means that by default when I create a new database there will be a table created in public schema called spatial_ref_sys . When I run flyway migrate on this database, I get the above error. Running init seems to create the public.schema_version table and mark version 1 as SUCCEDED without actually running the the

Migrating Stored Procedures with Flyway

南笙酒味 提交于 2019-11-29 12:45:52
问题 How should procedural database code like stored procedures be managed with a database migration tool like Flyway? Unlike DDL I would not want to see changes to a stored procedure stored within multiple database migration files. How can procedural code be managed within a single file under source control, but also take advantage of database migrations with a tool like Flyway? 回答1: There is no special construct in the framework to deal with this. Mainly because I haven't figured out a way to do

Pre- and Post-migration scripts for Flyway

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 10:33:06
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 the migration. Rebuild views and stored procedures. This insures that any change to the schema is reflected in related views and stored procedures. Steps (1) and (3) will be bash scripts. Is this possible in Flyway? Axel Fontaine Update 2014-04-29: This is now Possible with Flyway 3.0 by implementing the FlywayCallback interface. Previous answer The short answer is: no, not at this point. Here is

springcloud中使用flyway作数据迁移时要注意的问题

让人想犯罪 __ 提交于 2019-11-29 07:31:33
pom中引用flyway的core包 <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> <version>5.2.4</version> </dependency> 创建sql存放目录时要注意命名,如:db.migration,要先创建db目录再创建migration目录,因为在application.yml一般配置的是两级目录 flyway: baseline-on-migrate: true locations: classpath:/db/migration 如果每个微服务的resource中都有自己的db/migration,默认情况下会报 nested exception is org.flywaydb.core.api.FlywayException: Validate failed: Detected applied migration not resolved locally 这是因为通过 flyway_schema_history 表对本地sql文件进行连续性验证的结果,关闭验证即可。 flyway: baseline-on-migrate: true validate-on-migrate: false locations: classpath:

flyway与占位符 org.flywaydb.core.api.FlywayException: No value provided for placeholder expressions:

…衆ロ難τιáo~ 提交于 2019-11-29 07:30:15
当flyway遇到占位符$而报错的时候,解决方案: spring.flyway.placeholder-replacement=false 如果与maven相结合,解决方案: <plugin> <groupId>org.flywaydb</groupId> <artifactId>flyway-maven-plugin</artifactId> <version>5.2.4</version> <configuration> <url>jdbc:mysql://localhost:3306/test </url> <user>postgres</user> <password>java</password> <outOfOrder>true</outOfOrder> <baselineOnMigrate>true</baselineOnMigrate> <placeholderReplacement>false</placeholderReplacement> <encoding>UTF-8</encoding> <table>fsl_schema_version</table> <locations> <location>db/migration/</location> </locations> </configuration> </plugin> 在termal处执行命令:

Flyway multiple metadata tables in one schema

孤者浪人 提交于 2019-11-29 07:02:30
I'm trying to use Flyway to version the database of a modular application. Each module has its own separate set of tables, and migration scripts that will control the versioning of that set of tables. Flyway allows me to specify a different metadata table for each module - this way I can version each module independently. When I try to upgrade the application, I run a migration process for each module, each with its own table and set of scripts. Note that these tables are all in the same schema. However, when I try to migrate my application, the first migration is the only one that works.

Best way for “database specific” sql scripts with Flyway

*爱你&永不变心* 提交于 2019-11-29 02:56:39
I started to use Flyway in my current project for database migrations and I like it very much. I currently use Oracle in PROD- and Derby in TEST-Environment. Pretty soon, I did run in the problem of database specific sql commands, e.g. ALTER TABLE T1 MODIFY F1 VARCHAR(256); on Oracle vs ALTER TABLE T1 ALTER F1 SET DATA TYPE VARCHAR(256); on Derby. I can't see a way to write a "vendor neutral alter table modify column datatype" sql. What's the best way to deal with this problem using Flyway? You can use the flyway.locations property. In test in would look like this: flyway.locations=sql/common

How do placeholders work in Flyway?

久未见 提交于 2019-11-29 01:57:33
I'm evaluating Flyway for use in my project. Our current SQL scripts contain placeholders for things like URLs which will have a different domain names depending on the environment (dev, qa, prod). Specifically, we might have INSERT statements like INSERT INTO FEED VALUES ('app.${env.token}.company.org/feed1', 'My Feed'); ${env.token} needs to be replaced with 'dev', 'qa', or 'prod'. We have about 50 different properties that could potentially need replacement in SQL scripts. The properties all reside in one or two properties files. Is there a way to run the Flyway Ant migration task so that

Any way to “compress” Flyway migrations?

你离开我真会死。 提交于 2019-11-29 01:17:54
We are using Flyway to migrate the database schema and we already have more than 100 migration scripts. Once we "squashed" multiple migrations into a single first-version migration, this is ok during development, as we drop and recreate the schema. But in production this wouldn't work, as Flyway won't be able to validate the migrations. I couldn't find any documentation or best practice of what to do in this case. The problem is that the file quantity increases constantly, I don't want to see thousands of migration files everytime, essentially if production is already in the latest version. I

Schema related problems with Flyway / Spring and H2 embedded database

佐手、 提交于 2019-11-28 23:53:10
I am building a Spring 3 MVC app that uses a MySQL database and have recently integrated Flyway into the solution to manage the database migrations. I have successfully configured my applicationContext.xml according to the Flyway documentation such that, upon application startup, Flyway will migrate to the latest version. I am having trouble getting Flyway to play nicely with my unit / functional tests. I am using Spring Data JPA for my data access layer and have built some JUnit tests to test some custom queries. The application config I use for these tests is: <jdbc:embedded-database id=