Uploaded image for project: 'RH-SSO'
  1. RH-SSO
  2. RHSSO-1060

Add Primary Key Constraints to all tables of the database

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • RH-SSO-7.2.0.ER1
    • RH-SSO-7.1.1.GA
    • Server
    • None

      We're testing running Keycloak against a MySQL cluster, and we ran into this issue. It seems that MySQL cluster requires all tables to have a primary key constraint. Our DBA queried which ones are not compliant into the Keycloak schema and the result is the following:

      ------------------------------

      table_name

      ------------------------------

      ADMIN_EVENT_ENTITY
      CLIENT_DEFAULT_ROLES
      CLIENT_IDENTITY_PROV_MAPPING
      COMPOSITE_ROLE
      CREDENTIAL_ATTRIBUTE
      DATABASECHANGELOG
      FED_CREDENTIAL_ATTRIBUTE
      REALM_DEFAULT_GROUPS
      REALM_DEFAULT_ROLES
      REALM_ENABLED_EVENT_TYPES
      REALM_EVENTS_LISTENERS
      REALM_SUPPORTED_LOCALES
      REDIRECT_URIS
      WEB_ORIGINS

      ------------------------------

      We guessed the following constraints:

      alter table ADMIN_EVENT_ENTITY add primary key (ID);

      alter table CLIENT_DEFAULT_ROLES add primary key (CLIENT_ID,ROLE_ID);

      alter table CLIENT_IDENTITY_PROV_MAPPING add primary key (CLIENT_ID,IDENTITY_PROVIDER_ID);

      alter table COMPOSITE_ROLE add primary key (COMPOSITE,CHILD_ROLE);

      alter table CREDENTIAL_ATTRIBUTE add primary key (ID);

      alter table DATABASECHANGELOG add primary key (ID,ORDEREXECUTED);

      alter table FED_CREDENTIAL_ATTRIBUTE add primary key (ID);

      alter table REALM_DEFAULT_GROUPS add primary key (REALM_ID,GROUP_ID);

      alter table REALM_DEFAULT_ROLES add primary key (REALM_ID,ROLE_ID);

      alter table REALM_ENABLED_EVENT_TYPES add primary key (REALM_ID,`VALUE`);

      alter table REALM_EVENTS_LISTENERS add primary key (REALM_ID,`VALUE`);

      alter table REALM_SUPPORTED_LOCALES add primary key (REALM_ID,`VALUE`);
      alter table REDIRECT_URIS add primary key (CLIENT_ID,`VALUE`);

      alter table WEB_ORIGINS add primary key (CLIENT_ID,`VALUE`);

      But we would rather have an upstream solution.

            vramik@redhat.com Vlasta Ramik
            rhn-support-hokuda Hisanobu Okuda
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: