Revisit unique constraints in jpa user store

Closes #14797
This commit is contained in:
vramik 2022-10-12 11:42:17 +02:00 committed by Hynek Mlnařík
parent 0afc4a8af7
commit fa947a41ea
2 changed files with 7 additions and 1 deletions

View file

@ -65,7 +65,8 @@ import static org.keycloak.models.map.storage.jpa.JpaMapStorageProviderFactory.C
@Entity
@Table(name = "kc_user",
uniqueConstraints = {
@UniqueConstraint(columnNames = {"realmId", "username"}),
// if same username it can differ only in usernameWithCase
@UniqueConstraint(columnNames = {"realmId", "username", "usernameWithCase"}),
@UniqueConstraint(columnNames = {"realmId", "emailConstraint"})
})
@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonbType.class)})

View file

@ -34,4 +34,9 @@ limitations under the License.
</changeSet>
<changeSet author="keycloak" id="users-14797">
<addUniqueConstraint tableName="kc_user" columnNames="realmid, username, usernamewithcase"/>
<addUniqueConstraint tableName="kc_user" columnNames="realmid, emailconstraint"/>
</changeSet>
</databaseChangeLog>