Deferred indexes are not available on CockroachDB, therefore, only use them on PostgreSQL

Closes #12176
This commit is contained in:
Alexander Schwartz 2022-05-27 10:39:58 +02:00 committed by Pedro Igor
parent 86883fd68a
commit 063960aaa3
5 changed files with 35 additions and 10 deletions

View file

@ -57,8 +57,6 @@ limitations under the License.
<column name="name" type="VARCHAR(255)"/> <column name="name" type="VARCHAR(255)"/>
<column name="value" type="text"/> <column name="value" type="text"/>
</createTable> </createTable>
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<addUniqueConstraint tableName="kc_client_scope_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
<createIndex tableName="kc_client_scope_attribute" indexName="client_scope_attr_fk_root"> <createIndex tableName="kc_client_scope_attribute" indexName="client_scope_attr_fk_root">
<column name="fk_root"/> <column name="fk_root"/>
</createIndex> </createIndex>
@ -71,4 +69,11 @@ limitations under the License.
</modifySql> </modifySql>
</changeSet> </changeSet>
<changeSet author="keycloak" id="client-scopes-2" dbms="postgresql">
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<!-- this will not work on cockroachdb as deferred indexes are not supported in version 22.1 yet, therefore, only run it on postgresql -->
<!-- see https://go.crdb.dev/issue-v/31632/v21.2 for the current status of the implementation -->
<addUniqueConstraint tableName="kc_client_scope_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View file

@ -64,8 +64,6 @@ limitations under the License.
<column name="name" type="VARCHAR(255)"/> <column name="name" type="VARCHAR(255)"/>
<column name="value" type="text"/> <column name="value" type="text"/>
</createTable> </createTable>
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<addUniqueConstraint tableName="kc_client_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
<createIndex tableName="kc_client_attribute" indexName="client_attr_fk_root"> <createIndex tableName="kc_client_attribute" indexName="client_attr_fk_root">
<column name="fk_root"/> <column name="fk_root"/>
</createIndex> </createIndex>
@ -78,4 +76,11 @@ limitations under the License.
</modifySql> </modifySql>
</changeSet> </changeSet>
<changeSet author="keycloak" id="clients-2" dbms="postgresql">
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<!-- this will not work on cockroachdb as deferred indexes are not supported in version 22.1 yet, therefore, only run it on postgresql -->
<!-- see https://go.crdb.dev/issue-v/31632/v21.2 for the current status of the implementation -->
<addUniqueConstraint tableName="kc_client_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View file

@ -64,8 +64,6 @@ limitations under the License.
<column name="name" type="VARCHAR(255)"/> <column name="name" type="VARCHAR(255)"/>
<column name="value" type="text"/> <column name="value" type="text"/>
</createTable> </createTable>
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<addUniqueConstraint tableName="kc_group_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
<createIndex tableName="kc_group_attribute" indexName="group_attr_fk_root"> <createIndex tableName="kc_group_attribute" indexName="group_attr_fk_root">
<column name="fk_root"/> <column name="fk_root"/>
</createIndex> </createIndex>
@ -78,4 +76,11 @@ limitations under the License.
</modifySql> </modifySql>
</changeSet> </changeSet>
<changeSet author="keycloak" id="groups-2" dbms="postgresql">
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<!-- this will not work on cockroachdb as deferred indexes are not supported in version 22.1 yet, therefore, only run it on postgresql -->
<!-- see https://go.crdb.dev/issue-v/31632/v21.2 for the current status of the implementation -->
<addUniqueConstraint tableName="kc_group_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View file

@ -83,8 +83,6 @@ limitations under the License.
<column name="name" type="VARCHAR(255)"/> <column name="name" type="VARCHAR(255)"/>
<column name="value" type="TEXT"/> <column name="value" type="TEXT"/>
</createTable> </createTable>
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<addUniqueConstraint tableName="kc_realm_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
<createIndex tableName="kc_realm_attribute" indexName="realm_attr_fk_root"> <createIndex tableName="kc_realm_attribute" indexName="realm_attr_fk_root">
<column name="fk_root"/> <column name="fk_root"/>
</createIndex> </createIndex>
@ -97,4 +95,11 @@ limitations under the License.
</modifySql> </modifySql>
</changeSet> </changeSet>
<changeSet author="keycloak" id="realms-2" dbms="postgresql">
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<!-- this will not work on cockroachdb as deferred indexes are not supported in version 22.1 yet, therefore, only run it on postgresql -->
<!-- see https://go.crdb.dev/issue-v/31632/v21.2 for the current status of the implementation -->
<addUniqueConstraint tableName="kc_realm_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View file

@ -66,8 +66,6 @@ limitations under the License.
<column name="name" type="VARCHAR(255)"/> <column name="name" type="VARCHAR(255)"/>
<column name="value" type="text"/> <column name="value" type="text"/>
</createTable> </createTable>
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<addUniqueConstraint tableName="kc_role_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
<createIndex tableName="kc_role_attribute" indexName="role_attr_fk_root"> <createIndex tableName="kc_role_attribute" indexName="role_attr_fk_root">
<column name="fk_root"/> <column name="fk_root"/>
</createIndex> </createIndex>
@ -80,4 +78,11 @@ limitations under the License.
</modifySql> </modifySql>
</changeSet> </changeSet>
<changeSet author="keycloak" id="roles-2" dbms="postgresql">
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
<!-- this will not work on cockroachdb as deferred indexes are not supported in version 22.1 yet, therefore, only run it on postgresql -->
<!-- see https://go.crdb.dev/issue-v/31632/v21.2 for the current status of the implementation -->
<addUniqueConstraint tableName="kc_role_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
</changeSet>
</databaseChangeLog> </databaseChangeLog>