Flyway

How to create a database with flyway?

跟風遠走 提交于 2019-11-28 23:46:18
问题 Question: Is it possible to create a new DB in a migration script and then connect to it? How? My Scenario: I'm trying to use flyway in my Java project (RESTful application using Jersey2.4 + tomcat 7 + PostgreSQL 9.3.1 + EclipseLink) for managing the changes between different developers which are using git. I wrote my init script and ran it with: PGPASSWORD='123456' psql -U postgres -f migration/V1__initDB.sql and it worked fine. The problem is that I can't create new DB with my scripts. when

Can I use property file in maven pom.xml for flyway configuration

妖精的绣舞 提交于 2019-11-28 20:25:01
<plugin> <groupId>com.googlecode.flyway</groupId> <artifactId>flyway-maven-plugin</artifactId> <version>1.7</version> <configuration> <driver>com.mysql.jdbc.Driver</driver> <url>jdbc:mysql://127.0.0.1:3306/db_abc</url> <user>db_user</user> <sqlMigrationPrefix>V</sqlMigrationPrefix> </configuration> </plugin> I don't want to mention driver, url and user here. I already have a abc.property on src/main/resources . How can use that file here? Sébastien Le Callonnec Have a look at the properties-maven-plugin . It allows you to read properties from a file to then use them in your pom. Add the

How to use Flyway when working with feature branches

99封情书 提交于 2019-11-28 20:15:14
We have recently moved to using feature branches for each story we work on. These are as independent as possible, and our project manager then decides which stories will make up a release. This means that we do know the exact order in which stories will go into production initially. Is there a standard way of dealing with this in Flyway? I have read the FAQ which discusses how the change to the production database will be linear, which is correct. However I'm not sure how team members would decide what version numbers to give their migrations while they are working on their feature branch.

Embedded Postgres for Spring Boot Tests

放肆的年华 提交于 2019-11-28 19:41:08
I'm building a Spring Boot app, backed by Postgres, using Flyway for database migrations. I've been bumping up against issues where I cannot produce a migration that generates the desired outcome in both Postgres, and the embedded unit test database (even with Postgres compatibility mode enabled). So I am looking at using embedded Postgres for unit tests. I came across an embedded postgres implementation that looks promising, but don't really see how to set it up to run within Spring Boot's unit test framework only (for testing Spring Data repositories). How would one set this up using the

Liquibase or Flyway database migration alternative for Elasticsearch

痴心易碎 提交于 2019-11-28 19:14:19
I am pretty new to ES. I have been trying to search for a db migration tool for long and I could not find one. I am wondering if anyone could help to point me to the right direction. I would be using Elasticsearch as a primary datastore in my project. I would like to version all mapping and configuration changes / data import / data upgrades scripts which I run as I develop new modules in my project. In the past I used database versioning tools like Flyway or Liquibase. Are there any frameworks / scripts or methods I could use with ES to achieve something similar ? Does anyone have any

CDI Extension for Flyway

眉间皱痕 提交于 2019-11-28 17:12:28
问题 I tried to run flyway in my application before hibernate is hooking in on my JBoss AS 7.1. I tried with an @javax.ejb.Startup annotation, but this gets executed AFTER Hibernate is initialized and the database scheme is checked. So as far as I understand we can use a CDI Extension which hooks in before Hibernate is initialized. Is there some support for that out of the box for flyway? And if not, has anyone tried to do this before? 回答1: Ok I finally found out how to do this: I had to use the

How to roll back migrations using Flyway?

青春壹個敷衍的年華 提交于 2019-11-28 16:58:01
MyBatis migrations splits each SQL file into two sections: One for migrating forward one version One for migrating back one version How does one roll back versions using Flyway ? While Flyway supports rollbacks (as a commercial-only feature) its use is discouraged: https://flywaydb.org/documentation/command/undo While the idea of undo migrations is nice, unfortunately it sometimes breaks down in practice. As soon as you have destructive changes (drop, delete, truncate, …), you start getting into trouble. And even if you don’t, you end up creating home-made alternatives for restoring backups,

Spring beans are not injected in flyway java based migration

删除回忆录丶 提交于 2019-11-28 06:59:56
I'm trying to inject component of configuration properties in the flyway migration java code but it always null. I'm using spring boot with Flyway. @Component @ConfigurationProperties(prefix = "code") public class CodesProp { private String codePath; } Then inside Flyway migration code, trying to autowrire this component as following: public class V1_4__Migrate_codes_metadata implements SpringJdbcMigration { @Autowired private CodesProp codesProp ; public void migrate(JdbcTemplate jdbcTemplate) throws Exception { codesProp.getCodePath(); } Here, codesProp is always null. Is there any way to

Pre- and Post-migration scripts for Flyway

你。 提交于 2019-11-28 03:49:53
问题 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? 回答1: Update 2014-04-29: This is now Possible with Flyway 3.0 by implementing the

Liquibase or Flyway database migration alternative for Elasticsearch

二次信任 提交于 2019-11-27 20:30:10
问题 I am pretty new to ES. I have been trying to search for a db migration tool for long and I could not find one. I am wondering if anyone could help to point me to the right direction. I would be using Elasticsearch as a primary datastore in my project. I would like to version all mapping and configuration changes / data import / data upgrades scripts which I run as I develop new modules in my project. In the past I used database versioning tools like Flyway or Liquibase. Are there any