JHipster: Disabling liquibase - Can I disable liquibase for my project but still have the Jhipster generated tables(User, UserAuthority) be populated - jhipster

So for our use case all of our custom entity's already exist in the database. We dont want liquibase to handle any changes/updates to the entities in the database. I know this can be achieved by using liquibase.enabled: false in the yml file for the relevant profile. We will be using a hibernate setting to not start the app if the mappings to the database table arent correct.
However we would still like the JHipster generated classes for User/Authority/etc to be generated. Jhipster handles this with liquibase. I know on 1st application run up I can run with liquibase enabled and then from then on run with liquibase disabled?
Is there a better workflow for this I could do through configuration?

You can run Liquibase as a command line tool. In my project, we modified our pom.xml so that build generates both the app jar and a zip of the Liquibase migrations, both artifacts are deployed to a Nexus repository and our deployment tool executes Liquibase on unzipped migrations retrieved from the Nexus repo.
In addition, you can also use Liquibase contexts to restrict some migrations to some environments only: e.g to init admin password only in dev or test.

Related

Spring Boot Hibernate Liquibase db diff migration and update on startup

Since hibernate auto update is not appropriate for production deployment, I have replaced it by using Liquibase in order to migrate the production and development db.
I've based my config on those two great tutorials :
http://www.baeldung.com/liquibase-refactor-schema-of-java-app
http://www.operatornew.com/2017/07/automatic-db-migrations-for-spring-boot-with-liquibase.html
Everything is working fine in development however as far as I know I can't run mvn liquibase:diff and liquibase:update in production since the production server has no access to the application project.
In addition it could be nice to save time by avoiding running those maven command on each pull request. That's why I would like to know how could I run liquibase:diff on spring boot application startup to generate differences between current jpa model and db then update the db scheme without removing data with the db diff file using maven or java ?

how to deploy liquibase changes with grails 2.5

Grails puts the liquibase xml script files in the following location in the war:
WEB-INF/classes/migrations/
There are at least 5 strategies to get these changes onto the prodcution server, but none of them are viable:
set "grails.plugin.databasemigration.updateOnStart = true". This does not work as grails database migration plugin is hard coded to liquibase 2.0.5, which is full of bugs and is unusable. it creates a broken schema.
put the liquibase 3.3.5 jar on production server, then try to run it, pointing it to the war file to get the changelog files. This simply does not work. see "Unexpected error running Liquibase: Unknown Reason" liquibase 3.3.5 and grails war file
unpack the war, and run the liquibase command line against the unpacked changelog files. This is not possible in our case, as the jar command is not available on the production servers, and we cant add it.
deploy the war, which unpacks it, then run liquibase command line against the resultant files. This is the only solution we have found so far, but this has one major problem: as soon as you deploy the new war, it runs the app, without first updating the database, so users get crashes.
Some other solution?
Unfortunately, we cant find a way to get grails to produce two artifacts, the war and a separate file (e.g. a tar or zip) with just the liquibase files in it.
We don't have the benefit of continuous build servers or pupet scripts or similar, we just want to build and deploy simple applications as wars. Liquibase is a major hurdle to this, at least for grails 2.5 apps which are somewhat crippled with liquibase 2.0.5 bundled with them by default.
We could resort to hand copying the migrations directory, zipping it and supplying it along side the war to the customer, but it would be very easy to get these out of sync.
We have no spare servers or budget for automation or tools, unfortunately.
Any ideas or strategies?

How to execute migrations of plugins using Grails and database migration plugin?

We have modularized our application by creating one main app and multiple plugins. Grails plugins can bring their own domain classes. But when using the database migration plugin, I was not able to find a way to execute migrations delivered by a plugin.
For example: I've a report plugin and a Report domain class. A migration file should contain the schema (for creating the table):
report plugin:
+ -- grails-app/domain/com/acme/Report.groovy
|
+ -- /migrations/changelog.groovy
|
+ /version-1.0.groovy
How can I configure the database migration plugin to execute the changelog in the report-plugin?
I am using Grails 2.3.11 and the database migration plugin 1.4.1
Thanks for your help,
best regards,
Daniel
You just need db migration plugin on your main app and this is automatically keep track of the domain changes for all the in-place plugins in your application.We don't need to install db migration plugin on each of the application's plugin individually.
Please make sure all the plugins which includes domain are in-place for the main app i.e the one having db migration plugin.
You can make plugins in-place by simply adding this code to your main app's BuildConfig.groovy:
grails.plugin.location."${pluginName}" = "${pathToYourPlugin}"
You can also refer this blog on Effective Grails plugin development with in-place plugins.

grails 2.5 database migration plugin stuck with liquibase 2.0.5 - is it possible to hack a newer liquibase version?

Unfortunately, the db migration plugin is stuck with version 2.0.5 of liquibase, which has many bugs, some of which are show stoppers for us. However, liquibase 3.3. solves all of them.
We do not have the expertise needed to edit or modify the migration plugin written by Burt.
We need to use the plugin as we need to be able to auto-run the liquibase update on deployment of the war, atremote customer sites we have no access to (we just supply the war, the deploy it).
One solution might be to "hack" the 3.3. liquibase jar in. We see than in home.grails\ivy-cache\org.liquibase\liquibase-core is liquibase-core-2.0.5.jar
If we overrite this with a 3.3. jar, will ivy realise that its the wrong file, and do something like download it again?
If this is not an option, perhaps we could explode the produced war, swap out the war, and repack?
Of course, if the api which liquibase supplies has changed, this will all fail.
Any better suggestions not involving rocket science?
Our last resort is to completely abandon using the grails database migration plugin, and do everything by hand using the liquibase command line, which is very tedious.
Its very unlikely that we would be able to change to grails 3, unfortunately.

Is it possible to have a grails app choose between hibernate and mongodb at runtime

I'm trying to build a Grails App. I want the user who installs this grails app on their tomcat instance be able to choose whether they want to use hibernate with an rdbms or mongodb while deploying the app.
Is it possible to have both plugins hibernate and mongodb and pick one based on a config file?
Alternately is it possible to create two builds of the grails app with exactly same code, but different a plugin, so that the user can pick either build?
The second option is your best bet. If both plugins are installed you need to use the mapWith attribute to indicate which to use, and that's a static field in your domain classes.
But if you don't install the Mongo plugin all domain classes will use Hibernate, and if you uninstall the Hibernate plugin and install the Mongo plugin, all domain classes will use Mongo. That would be very easy to script - either run grails war (for Hibernate) or grails uninstall-plugin hibernate, grails install-plugin mongodb, and grails war (for Mongo).

Resources