Choose alternatives for CockroachDB for referenced computed columns (#12991)
This commit is contained in:
parent
f2d71cd1c7
commit
d4c97bd3a9
4 changed files with 62 additions and 15 deletions
|
@ -58,6 +58,12 @@ limitations under the License.
|
|||
<ext:column jsonColumn="metadata" jsonProperty="fGrantedTimestamp"/>
|
||||
</ext:createJsonIndex>
|
||||
<addUniqueConstraint columnNames="realmid, resourceserverid, scopeid, resourceid, owner, requester" tableName="kc_authz_permission"/>
|
||||
</changeSet>
|
||||
|
||||
<!-- unimplemented on CockroachDB: computed column "XXX" cannot reference a foreign key
|
||||
See: https://go.crdb.dev/issue-v/46672/v21.2 -->
|
||||
|
||||
<changeSet author="keycloak" id="authz-permission-2" dbms="postgresql">
|
||||
<addForeignKeyConstraint constraintName="authz_permission_fk_root_fkey"
|
||||
baseTableName="kc_authz_permission"
|
||||
baseColumnNames="resourceserverid"
|
||||
|
@ -67,4 +73,11 @@ limitations under the License.
|
|||
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="keycloak" id="authz-permission-3" dbms="cockroachdb">
|
||||
<!-- placeholder for foreign key on computed column to allow fast looking by resourceserverid -->
|
||||
<createIndex tableName="kc_authz_permission" indexName="authz_permission_fk_root_fkey">
|
||||
<column name="resourceserverid"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
@ -52,12 +52,6 @@ limitations under the License.
|
|||
<createIndex tableName="kc_authz_policy" indexName="authz_policy_type">
|
||||
<column name="type"/>
|
||||
</createIndex>
|
||||
<addForeignKeyConstraint constraintName="authz_policy_fk_root_fkey"
|
||||
baseTableName="kc_authz_policy"
|
||||
baseColumnNames="resourceserverid"
|
||||
referencedTableName="kc_authz_resource_server"
|
||||
referencedColumnNames="id"
|
||||
onDelete="CASCADE"/>
|
||||
|
||||
<createTable tableName="kc_authz_policy_scope">
|
||||
<column name="policy_id" type="UUID">
|
||||
|
@ -118,8 +112,6 @@ limitations under the License.
|
|||
<column name="fk_root"/>
|
||||
<column name="name"/>
|
||||
</createIndex>
|
||||
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
|
||||
<addUniqueConstraint tableName="kc_authz_policy_config" columnNames="fk_root, name" deferrable="true" initiallyDeferred="true" />
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="keycloak" id="authz-policy-2" dbms="postgresql">
|
||||
|
@ -129,5 +121,25 @@ limitations under the License.
|
|||
<addUniqueConstraint tableName="kc_authz_policy_scope" columnNames="policy_id, scope_id" deferrable="true" initiallyDeferred="true" />
|
||||
<addUniqueConstraint tableName="kc_authz_policy_resource" columnNames="policy_id, resource_id" deferrable="true" initiallyDeferred="true" />
|
||||
<addUniqueConstraint tableName="kc_authz_policy_associated_policy" columnNames="policy_id, associated_policy_id" deferrable="true" initiallyDeferred="true" />
|
||||
|
||||
<!-- this is deferrable and initiallyDeferred as hibernate will first insert new entries and then delete the old by default -->
|
||||
<addUniqueConstraint tableName="kc_authz_policy_config" columnNames="fk_root, name" deferrable="true" initiallyDeferred="true" />
|
||||
|
||||
<!-- unimplemented on CockroachDB: computed column "XXX" cannot reference a foreign key
|
||||
See: https://go.crdb.dev/issue-v/46672/v21.2 -->
|
||||
<addForeignKeyConstraint constraintName="authz_policy_fk_root_fkey"
|
||||
baseTableName="kc_authz_policy"
|
||||
baseColumnNames="resourceserverid"
|
||||
referencedTableName="kc_authz_resource_server"
|
||||
referencedColumnNames="id"
|
||||
onDelete="CASCADE"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="keycloak" id="authz-policy-3" dbms="cockroachdb">
|
||||
<!-- placeholder for foreign key on computed column to allow fast looking by resourceserverid -->
|
||||
<createIndex tableName="kc_authz_policy" indexName="authz_policy_fk_root_fkey">
|
||||
<column name="resourceserverid"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
@ -56,12 +56,6 @@ limitations under the License.
|
|||
<column name="name"/>
|
||||
</createIndex>
|
||||
<addUniqueConstraint tableName="kc_authz_resource" columnNames="realmid, resourceserverid, name, owner"/>
|
||||
<addForeignKeyConstraint constraintName="authz_resource_fk_root_fkey"
|
||||
baseTableName="kc_authz_resource"
|
||||
baseColumnNames="resourceserverid"
|
||||
referencedTableName="kc_authz_resource_server"
|
||||
referencedColumnNames="id"
|
||||
onDelete="CASCADE"/>
|
||||
|
||||
<createTable tableName="kc_authz_resource_scope">
|
||||
<column name="resource_id" type="UUID">
|
||||
|
@ -117,6 +111,22 @@ limitations under the License.
|
|||
<!-- see https://go.crdb.dev/issue-v/31632/v21.2 for the current status of the implementation -->
|
||||
<addUniqueConstraint tableName="kc_authz_resource_scope" columnNames="resource_id, scope_id" deferrable="true" initiallyDeferred="true" />
|
||||
<addUniqueConstraint tableName="kc_authz_resource_attribute" columnNames="fk_root, name, value" deferrable="true" initiallyDeferred="true" />
|
||||
|
||||
<!-- unimplemented on CockroachDB: computed column "XXX" cannot reference a foreign key
|
||||
See: https://go.crdb.dev/issue-v/46672/v21.2 -->
|
||||
<addForeignKeyConstraint constraintName="authz_resource_fk_root_fkey"
|
||||
baseTableName="kc_authz_resource"
|
||||
baseColumnNames="resourceserverid"
|
||||
referencedTableName="kc_authz_resource_server"
|
||||
referencedColumnNames="id"
|
||||
onDelete="CASCADE"/>
|
||||
</changeSet>
|
||||
|
||||
|
||||
<changeSet author="keycloak" id="authz-resource-3" dbms="cockroachdb">
|
||||
<!-- placeholder for foreign key on computed column to allow fast looking by resourceserverid -->
|
||||
<createIndex tableName="kc_authz_resource" indexName="authz_resource_fk_root_fkey">
|
||||
<column name="resourceserverid"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
@ -48,6 +48,11 @@ limitations under the License.
|
|||
<column name="resourceserverid"/>
|
||||
<column name="name"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
<!-- unimplemented on CockroachDB: computed column "XXX" cannot reference a foreign key
|
||||
See: https://go.crdb.dev/issue-v/46672/v21.2 -->
|
||||
<changeSet author="keycloak" id="authz-scope-2" dbms="postgresql">
|
||||
<addForeignKeyConstraint constraintName="authz_scope_fk_root_fkey"
|
||||
baseTableName="kc_authz_scope"
|
||||
baseColumnNames="resourceserverid"
|
||||
|
@ -57,4 +62,11 @@ limitations under the License.
|
|||
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="keycloak" id="authz-scope-3" dbms="cockroachdb">
|
||||
<!-- placeholder for foreign key on computed column to allow fast looking by resourceserverid -->
|
||||
<createIndex tableName="kc_authz_scope" indexName="authz_scope_fk_root_fkey">
|
||||
<column name="resourceserverid"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
Loading…
Reference in a new issue