Flyway

Several app instances trying to migrate the same database at the same time

╄→尐↘猪︶ㄣ 提交于 2019-12-06 07:42:06
问题 I just started using flyway in a pretty standard spring 2.5 web application with a mysql databse. It has been in production for years and has a lot of data. I hooked it up to auto-migrate on startup with <bean id="flyway" class="com.googlecode.flyway.core.Flyway" init-method="migrate"> <property name="dataSource" ref="dataSource"/> </bean> and the made the Spring's persistence unit manager (using jpa) depend on it so the database would be migrated before JPA initializes. This works fine. In

Flyway: Strategy for migrating frequently changing functions / stored procedures

独自空忆成欢 提交于 2019-12-06 04:38:58
问题 My question is, has anyone found a satisfactory formula for migration large and frequently changing stored procedures? This question touches on it and has a response from the Flyway author but it's been over a year and a major release with exciting new framework hooks has since been published. I've added a more thorough description of the problem and my current solution to this flyway github issue but I thought I'd reach out to a wider audience. As described, I have a working solution but has

how to resolve version number conflicts of script in flywaydb

淺唱寂寞╮ 提交于 2019-12-06 04:23:12
问题 I got 3 git branches: develop, fixbug, and master. The latest FlywayDB script version in branch master is 1.2.43, and the one in branch develop is 1.2.54. Branch fixbug's script version is update to 1.2.55, and it is based on branch master. I need to merge branch fixbug to branch master, and to deploy master(version 1.2.55) to production environment first. As we know, flywayDB executes scripts in order, from low version to high version. If I do so, when I deploy branch develop(version 1.2.54)

Flyway Spring Boot Autowired Beans with JPA Dependency

狂风中的少年 提交于 2019-12-06 03:51:40
I am using Flyway 5.0.5 and I am unable to create a java (SpringJdbcMigration) with autowired properties... They end up null . The closest thing I can find is this question: Spring beans are not injected in flyway java based migration The answer mentions it being fixed in Flyway 5 but the links are dead. What am I missing? refeniz I struggled with this for a long time due to my JPA dependency. I am going to edit the title of my question slightly to reflect this... @Autowired beans are instantiated from the ApplicationContext . We can create a different bean that is ApplicationContextAware and

Flyway's support for Groovy-migrations & conditional environment-specific data insertions

无人久伴 提交于 2019-12-05 17:48:41
We are working on a Grails-project, and exploring Flyway as a db-migration tool for us. In our current architecture, we rely on Groovy-migration scripts (executed at application-startup) for conditional environment-specific data insertions (say 'some-data' in 'tableA' for Production against 'other-data' in the same table 'tableA' for pre-Production). Q1. Does Flyway support Groovy-migration scripts? Q2. If not, then how best can we achieve conditional environment-specific data insertions? Q1: Java-based migrations are loaded as binary classes at runtime. Whether the source was Java or Groovy

Best practice: How to modify flyway migration script after it has been used

空扰寡人 提交于 2019-12-05 15:44:09
问题 I am looking for advise in the following case. I set up flyway and migration scripts in my productive environment. On every deployment the database will be migrated to the current version. I already have created several migrations scripts which have been applied to the productive database. Recently I upgraded my development MySQL tools which now include warnings about usage of deprecated functions and other warnings. These warnings have not been displayed in the old version. Of course I would

flyway数据脚本版本控制

安稳与你 提交于 2019-12-05 14:06:07
1.数据库没有 flyway_schema_history 表 配置文件设置 baseline-on-migrate: true :当迁移的时候 没有 flyway_schema_history 表 时,会创建flyway_schema_history 并且默认从 V1开始执行 会创建 flyway_schema_history flyway.baseline-on-migrate当迁移时发现目标schema非空,而且带有没有元数据的表时,是否自动执行基准迁移,默认false. flyway.baseline-version开始执行基准迁移时对现有的schema的版本打标签,默认值为1. 2. 数据库有 flyway_schema_history 表 从当前记录 开始执行 V 版本,之前已经指定的V 记录,会通过 checksum来检验 之前的脚本 来源: https://my.oschina.net/u/2870118/blog/3133371

Flyway migrations not persistent in H2 embedded database

泄露秘密 提交于 2019-12-05 11:24:37
I'm actually writing a small web application with spring boot and wanted to use a (embedded) H2 database together with Spring Data JPA and Flyway for database migration. This is my application.properties: spring.datasource.url=jdbc:h2:~/database;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1; spring.datasource.username=admin spring.datasource.password=admin spring.datasource.driver-class-name=org.h2.Driver In the main() method of my @SpringBootApplication class I do the following: ResourceBundle applicationProperties = ResourceBundle.getBundle("application"); Flyway flyway = new Flyway(); flyway

Integration Testing with Flyway

非 Y 不嫁゛ 提交于 2019-12-05 08:57:46
I'm using Flyway to handle the database migration. Everything is working fine: the default location of the migration files is: main/resource/db/migration/V1... I am running integration tests and my setup uses an separate database schema for integration, which I would like to manage with flyway as well. The integration tests, though, are located in the test folder (not main ). When the Flyway bean executes migrate() , it doesn't find the migration files because they are in the main folder. If I put the migration files in test/resource/db/migration/V1... it works. I really don't want to have to

Flyway migration hangs for postgres CREATE INDEX CONCURRENTLY

泪湿孤枕 提交于 2019-12-05 08:01:53
I am trying to run a CREATE INDEX CONCURRENTLY command against a Postgres 9.2 database. I implemented a MigrationResolver as shown in issue 655 . When this migration step is run via mvn flyway:migrate or similar, the command starts but hangs in waiting mode. I verified that the command is executing via the pg_stat_activity table: test_2015_04_13_110536=# select * from pg_stat_activity; datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | waiting | state | query -------+-----------