This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migrations for breakdown of EntityType in ORD Service (#3921)
- Loading branch information
1 parent
668c105
commit eb2c22d
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...s/schema-migrator/migrations/director/20240518141635_ord_api_events_entity_types.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BEGIN; | ||
|
||
DROP VIEW IF EXISTS tenants_api_entity_types; | ||
DROP VIEW IF EXISTS tenants_event_entity_types; | ||
|
||
COMMIT; |
122 changes: 122 additions & 0 deletions
122
...nts/schema-migrator/migrations/director/20240518141635_ord_api_events_entity_types.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
BEGIN; | ||
|
||
-- create views that will represent the relation between events/apis and entityTypes | ||
-- the joins are based on the ordId of the entityTypeMapping.entityTypeTargets.ordId and the entityType.ordId | ||
-- then the event/api internal id is taken from the entityTypeMapping | ||
|
||
CREATE OR REPLACE VIEW tenants_event_entity_types | ||
(event_definition_id, tenant_id, formation_id, id, ord_id, app_id, local_tenant_id, level, title, short_description, description, | ||
system_instance_aware, changelog_entries, package_id, visibility, links, part_of_products, last_update, | ||
policy_level, custom_policy_level, release_status, sunset_date, successors, extensible_supported, | ||
extensible_description, tags, labels, documentation_labels, resource_hash, version_value, | ||
version_deprecated, version_deprecated_since, version_for_removal, deprecation_date) | ||
AS | ||
SELECT DISTINCT etm.event_definition_id, | ||
t_apps.tenant_id, | ||
t_apps.formation_id, | ||
et.id, | ||
et.ord_id, | ||
et.app_id, | ||
et.local_tenant_id, | ||
et.level, | ||
et.title, | ||
et.short_description, | ||
et.description, | ||
et.system_instance_aware, | ||
et.changelog_entries, | ||
et.package_id, | ||
et.visibility, | ||
et.links, | ||
et.part_of_products, | ||
et.last_update, | ||
et.policy_level, | ||
et.custom_policy_level, | ||
et.release_status, | ||
et.sunset_date, | ||
et.successors, | ||
actions.supported AS extensible_supported, | ||
actions.description AS extensible_description, | ||
et.tags, | ||
et.labels, | ||
et.documentation_labels, | ||
et.resource_hash, | ||
et.version_value, | ||
et.version_deprecated, | ||
et.version_deprecated_since, | ||
et.version_for_removal, | ||
et.deprecation_date | ||
FROM entity_types et | ||
JOIN (SELECT a1.id, | ||
a1.tenant_id, | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid AS formation_id | ||
FROM tenant_applications a1 | ||
UNION ALL | ||
SELECT af.app_id, | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'::uuid AS tenant_id, | ||
af.formation_id | ||
FROM apps_formations_id af | ||
UNION ALL | ||
SELECT apps_subaccounts.id, | ||
apps_subaccounts.tenant_id, | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid AS formation_id | ||
FROM apps_subaccounts) t_apps ON et.app_id = t_apps.id, entity_type_mappings etm, jsonb_to_recordset(etm.entity_type_targets) AS entries("ordId" TEXT, "correlationId" TEXT), JSONB_TO_RECORD(et.extensible) actions(supported text, description text) WHERE entries."ordId" = et.ord_id AND etm.event_definition_id IS NOT NULL; | ||
|
||
|
||
CREATE OR REPLACE VIEW tenants_api_entity_types | ||
(api_definition_id, tenant_id, formation_id, id, ord_id, app_id, local_tenant_id, level, title, short_description, description, | ||
system_instance_aware, changelog_entries, package_id, visibility, links, part_of_products, last_update, | ||
policy_level, custom_policy_level, release_status, sunset_date, successors, extensible_supported, | ||
extensible_description, tags, labels, documentation_labels, resource_hash, version_value, | ||
version_deprecated, version_deprecated_since, version_for_removal, deprecation_date) | ||
AS | ||
SELECT DISTINCT etm.api_definition_id, | ||
t_apps.tenant_id, | ||
t_apps.formation_id, | ||
et.id, | ||
et.ord_id, | ||
et.app_id, | ||
et.local_tenant_id, | ||
et.level, | ||
et.title, | ||
et.short_description, | ||
et.description, | ||
et.system_instance_aware, | ||
et.changelog_entries, | ||
et.package_id, | ||
et.visibility, | ||
et.links, | ||
et.part_of_products, | ||
et.last_update, | ||
et.policy_level, | ||
et.custom_policy_level, | ||
et.release_status, | ||
et.sunset_date, | ||
et.successors, | ||
actions.supported AS extensible_supported, | ||
actions.description AS extensible_description, | ||
et.tags, | ||
et.labels, | ||
et.documentation_labels, | ||
et.resource_hash, | ||
et.version_value, | ||
et.version_deprecated, | ||
et.version_deprecated_since, | ||
et.version_for_removal, | ||
et.deprecation_date | ||
FROM entity_types et | ||
JOIN (SELECT a1.id, | ||
a1.tenant_id, | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid AS formation_id | ||
FROM tenant_applications a1 | ||
UNION ALL | ||
SELECT af.app_id, | ||
'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'::uuid AS tenant_id, | ||
af.formation_id | ||
FROM apps_formations_id af | ||
UNION ALL | ||
SELECT apps_subaccounts.id, | ||
apps_subaccounts.tenant_id, | ||
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid AS formation_id | ||
FROM apps_subaccounts) t_apps ON et.app_id = t_apps.id, entity_type_mappings etm, jsonb_to_recordset(etm.entity_type_targets) AS entries("ordId" TEXT, "correlationId" TEXT), JSONB_TO_RECORD(et.extensible) actions(supported text, description text) WHERE entries."ordId" = et.ord_id AND etm.api_definition_id IS NOT NULL; | ||
|
||
COMMIT; |