Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-13908

Database Migration to >=9.0.1 fails on MySQL

    XMLWordPrintable

    Details

    • Steps to Reproduce:
      • Setup Keycloak 7.0.1 on MySQL
      • Insert a duplicate in KEYCLOAK_GROUPS (myrealm, mygroup, NULL)
      • Run the migration to 9.0.3
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      Workaround is, that before migrating to new version, you will make sure that groups are not duplicated at the top level. So instead of having 2 groups "group-1" in same realm, you will rename one of them to something like "group-2" . This needs to be done in the old Keycloak version.

      Show
      Workaround is, that before migrating to new version, you will make sure that groups are not duplicated at the top level. So instead of having 2 groups "group-1" in same realm, you will rename one of them to something like "group-2" . This needs to be done in the old Keycloak version.
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      We are currently running Keycloak 7.0.1 on MySQL.The table KEYCLOAK_GROUPS contains duplicate records like this:

      (realm-1, group-1, NULL)
      (realm-1, group-1, NULL)

      where the third value is meant to be PARENT_GROUP.

      The database migration to Keycloak 9.0.3 then exits with the following error:

      15:30:15,882 ERROR [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool -- 72) Change Set META-INF/jpa-changelog-9.0.1.xml::9.0.1-KEYCLOAK-12579-add-not-null-constraint::keycloak failed.  Error: Duplicate entry 'realm-name- -group-name' for key 'SIBLING_NAMES' [Failed SQL: UPDATE keycloak.KEYCLOAK_GROUP SET PARENT_GROUP = ' ' WHERE PARENT_GROUP IS NULL]
      15:30:15,888 FATAL [org.keycloak.services] (ServerService Thread Pool -- 72) java.lang.RuntimeException: Failed to update database
      

      The existing SIBLING_NAMES constraint prevents the update of PARENT_GROUP to the new default value " " (one whitespace) on all our group duplicates as described above.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rhn-support-rmartinc Ricardo Martin Camarero
              Reporter:
              jenshoffmann1001 Jens Hoffmann (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: