I want to disable flyway for a certain environment but can't find a way to do it
Below are the version of stack
Spring - 3.2
Flyway - 4.0.3
Mysql - 5.6.3
Exploring flyway and open to any approach for disabling to
Looked for a lot, but all I can find is how to disable it for spring-boot.
Can anyone please help?
Also I want to use core spring this features through spring and maven, and not via java classes
If you could update Spring to version 4 you could use the #Conditional with a custom Condition to create the Flyway bean conditionally.
Related
I'm trying to upgrade Camunda version in one of my current Spring Boot projects - from 7.14.0 to 7.18.0.
I've changed the versions of Camunda libs and from the application perspective everything works great, but I'm concidering If I should also make some changes in the database schema to avoid problems with past non-finished processes?
I've read camunda docs and found the latest patch: 'engine_7.14_patch_7.14.2_to_7.14.3.sql'
https://docs.camunda.org/manual/7.18/installation/database-schema/#liquibase-patch-level-update
https://jira.camunda.com/browse/CAM-12832
Does it mean that after version 17.4.3 db schema stays the same?
If not can someone provide me some tips where can I find any informations about the migrations steps?
Pleas efollow
https://docs.camunda.org/manual/7.18/update/minor/714-to-715/
https://docs.camunda.org/manual/7.18/update/minor/715-to-716/
https://docs.camunda.org/manual/7.18/update/minor/716-to-717/
https://docs.camunda.org/manual/7.18/update/minor/717-to-718/
to get from 7.14 to 7.18.
I started Spring Project. I have added some dependencies.
Previously, I were commenting some dependencies as Security, Mysql driver, if it is not needed for me.
But how to disable them without commenting dependencies?
Maybe some properties are needed for that?
For example, I want to use H2Database to test project, but PostgreSQL I will use later. Or Spring Security, for example.
Do I have to use Spring Boot Profiles?
You are probably looking for profiles. You can read about it more eg: https://www.mkyong.com/spring/spring-profiles-example/
You may need to implement profiling for this. You can read about it more.
https://dzone.com/articles/spring-boot-profiles-1
I am upgrading my spring boot version from 1.4.4 to 2.0.0 having hibernate version 4.3.11. But it looks like that spring boot 2.0.0 doesn't support hibernate version 4.x.x.
Initially, it gives me the entityManagerFactory error so I manually providede the entityManagerFactoryBean but after that, I am stuck with the following error
java.lang.ClassNotFoundException: org.hibernate.boot.model.naming.PhysicalNamingStrategy
Is there any workaround for this. I can't update my hibernate version for now because of some legacy code.
Migrating from Spring Boot version 1 to version 2 is a big upgrade, you can check their migration guide as many things changed. We did a similar upgrade from 1.5 to 2.1 and it took us two weeks to complete it.
If you really must use Spring Boot 2 and Hibernate 4, you could always force exclude the new dependencies in your dependency manager, but that would (1) defeat the purpose of using newer version and (2) generate similar amount of work as if you were refactoring your code to support new version anyway
So, let's consider a general Spring boot application, which uses JOOQ for database database access, and Flyway for database migration. The project uses gradle for dependency management.
I want the following things:
Run my application in docker. So, I want to use only in environment variables (https://12factor.net/config). Hence, I don't know, how to configure both spring boot application properties (database login and password) and gradle JOOQ plugin database login and password.
Automatic generation JOOQ classes. Flyway migration runs, when an application has started. But JOOQ generates code in gradle build task. So, we see wrong order of tasks execution.
I have a very similar setup, but resorted to manual action to generate Jooq classes.
I need them for development, so it makes no sense for me to delay the generation till target environment.
I decided to run a local dB for development purposes.
I run it in docker, but this is a detail in the entire setup.
When I have a new migration, I run it with flyway grade plugin against the local dB. Then I regenerate Jooq classes with grade Jooq plugin.
When the app is deployed in the target environment, I rely on flyway to run migration on startup. I have matching Jooq classes packaged, so everything works smoothly.
The jOOQ GitHub project has an example project that uses jOOQ with Spring Boot and the sql-maven-plugin.
You can easily replace the sql-maven-plugin by the Flyway plugin as demonstrated in the jOOQ/Flyway example project or this blog post.
On a related note, in case you're using one of the commercial distributions of jOOQ with Spring Boot, this is documented in this blog post here.
There is the following gradle task, which requires flyway, otj-pg-embedded, jooq and postgresql driver:
import com.opentable.db.postgres.embedded.*
import org.flywaydb.core.*
import org.jooq.codegen.*
tasks.named("compileKotlin") {
doFirst {
//create embedded postgresql
EmbeddedPostgres.builder().setPort(5400).start().use {
//migrate embedded posrtgresql
Flyway.configure()
.locations("filesystem:$projectDir/migrations/")
.schemas("public")
.dataSource(it.postgresDatabase)
.load()
.migrate()
//generate jooq classes
GenerationTool.generate("some xml for jooq")
}
}
}
The source is https://gist.github.com/whyoleg/63195b60eb85e8fe2114b30f28b892ef
We've been working with Grails for a while and my Team Lead raised some questions about the Grails ORM (GORM):
How do we maintain the database schema once we have moved to production?
Can we update the database schema with Grails?
If the schema is updated, will the changes be automatically reflected / does the framework take care of this?
Is there any plugin for Grails that will allow us to update the schema without headaches?
I recently released the official Grails plugin for database migrations - see http://grails.org/plugin/database-migration and the docs at http://grails-plugins.github.com/grails-database-migration/docs/manual/index.html
I'm working with the author of Liquibase on this, so the older liquibase plugin is now deprecated and the new one should be used since it uses the latest version of Liquibase (2.0) and is officially supported by SpringSource. See http://blog.liquibase.org/2011/01/new-standard-liquibase-plugin-grails-database-migration.html for his announcement.
Ask usage questions on the Grails User mailing list (signup from http://grails.org/Mailing+lists) or the new plugin forum at http://grails-plugins.847840.n3.nabble.com/ or email the author directly :)
Remove dbCreate parameter in DataSource.groovy for your production environment - this will stop GORM from auto-updating DB schema.
Sure. Use LiquiBase plugin.
GORM can do it with dbCreate='update', but it's strongly not recommended. For instance, if you rename a field, GORM/LiquiBase can never determine that you have to migrate the data, and not just drop+create.
In one line: grails db-diff to generate LiquiBase's changelog.xml, and grails migrate -Dgrails.env=<whatever environment> to apply it to respective db server.
While the "auto create" functionality is ok to get a project up and running I find liquibase the best way to keep the db up-to-date. There is a grails plugin and I believe work is under way on a DSL too.
So, create a baseline schema (you could use liquibase's generate-changelog) then make all future changes through liquibase and it will manage the updates, rollbacks and even some db interop for you. You can set your DataSource.groovy config to verify and grails will not start up if the schema does not match the domain config:
environments {
development {
dataSource {
dbCreate = "validate"
You may also be interested in the liquibase-runner plugin to run your migrations on application start.