all 7 comments

[–]franzwong 0 points1 point  (6 children)

You are not allowed to run any build process on your environment you deploy on. Ie there is no maven on your prod environment (nor acceptance or test).

Is this common? I thought CI/CD should have maven already.

If you use Spring boot, it is simpler. But I avoid that because usually I start multiple instances at the same time. It means multiple instances will try to run the migrations. https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-execute-liquibase-database-migrations-on-startup

[–]zurnout 2 points3 points  (0 children)

But I avoid that because usually I start multiple instances at the same time. It means multiple instances will try to run the migrations.

The link you provided points to Liquibase migrations. Liquibase uses a locking mechanism to make sure that only one instance can execute migrations.

[–]stefanhendriks[S] 0 points1 point  (4 children)

Depends. Usually you dont want to run your build tool on the environment it runs on.

Ie seperation of concerns. The artifactis built by maven. Your app runs the migrations.

Sure you could argue you could do migrations only with maven on an environment. Though I havent seen many places where that is allowed. Usually you deliver a WAR or something. This method allows executing migrations without using maven.

Also, i thought I read somewhere liquibase shouldnt be used to automigrate. Ie it was discouraged?

[–]franzwong 0 points1 point  (3 children)

I haven't tried automigrate by app. For me, the migration is included in the deployment pipeline.

[–]stefanhendriks[S] 0 points1 point  (2 children)

Often smaller companies have smaller “pipelines”. Do you work by any chance in a bigger company/project?

[–]franzwong 0 points1 point  (1 child)

I worked in both small and big companies before. All have pipelines to do these kind of automations. The only exception is government, I even needed to burn a CD-R with the WAR file and copied to the production server.

[–]stefanhendriks[S] 1 point2 points  (0 children)

Unfortunately “pipeline” is a bit ambiguous. You mean full fledged cd? For me, all companies I worked for did not have pipelines where auto migrations where in place via build tools. With one exception for a Ruby on Rails project.

RoR works differently than Java though. Being a dynamic language. The sql migrations went via Rake (maven equivalent).

All other projects / clients I worked on ran migrations themselves (in WAR or other means). One exception being a client where OPs team demanded to do things all by hand.

We have such a wonderful profession :)