p2-inc / keycloak-orgs

Single realm, multi-tenancy for SaaS apps
https://phasetwo.io
Other
389 stars 66 forks source link

Add support for MySQL #42

Closed xgp closed 1 year ago

xgp commented 1 year ago

Implement MySQL support for migrations.

See @phamann's PR: https://github.com/p2-inc/keycloak-orgs/pull/41 Branch: https://github.com/fastly/keycloak-orgs/tree/phamann/mysql-support

xgp commented 1 year ago

Reopening, as we've found that users with existing deployments are getting checksum errors when upgrading. E.g.

2023-03-10 19:01:00,220 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) Error details:: java.lang.RuntimeException: liquibase.exception.ValidationFailedException: Validation Failed:
      1 changesets check sum
           META-INF/jpa-changelog-phasetwo-20211208.xml::drop-column-user-org-role-org-0::garth was: 8:9438fc2451042432ce89495003fcb8cc but is now: 8:7776fbcd4917bc8d6110eedb5a638479
xgp commented 1 year ago

Interesting. Looks like that changeset used to have a catalogName="cat" in the dropUniqueConstraint action. Liquibase is supposed to calculate the same checksum even when adding preconditions, but because we removed the catalogName="cat" in the PR, it calculated a different one. I added a validCheckSum per the recommendation here https://www.liquibase.com/blog/what-affects-changeset-checksums and will try in an environment where this is known to happen.

xgp commented 1 year ago

The validCheckSum seems to get ignored in some environments. Tried the old and new checksums and 1:any and ANY values.

xgp commented 1 year ago

Argh. The validCheckSum addition with the new checksum does work. I had a build cache issue. Solved.

phamann commented 1 year ago

Oh no! Sorry that I didn't catch this in my original PR, @xgp, glad the fix was realtively simple.