Fix #7100 Upgrade issues for 0.12 release (#7101)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-09-01 22:22:42 -07:00 committed by GitHub
parent 726f7ddf27
commit 2f84bfbfa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 16 deletions

View File

@ -109,4 +109,10 @@ DELETE FROM entity_extension
WHERE jsonSchema IN ('tableProfile', 'columnTest', 'tableTest'); WHERE jsonSchema IN ('tableProfile', 'columnTest', 'tableTest');
DELETE FROM ingestion_pipeline_entity DELETE FROM ingestion_pipeline_entity
WHERE LOWER(JSON_EXTRACT(json, '$.pipelineType') = 'profiler'); WHERE LOWER(JSON_EXTRACT(json, '$.pipelineType') = 'profiler');
DELETE FROM role_entity;
DELETE FROM policy_entity;
DELETE FROM field_relationship WHERE fromType IN ('role', 'policy') OR toType IN ('role', 'policy');
DELETE FROM entity_relationship WHERE fromEntity IN ('role', 'policy') OR toEntity IN ('role', 'policy');
ALTER TABLE role_entity DROP COLUMN defaultRole;

View File

@ -105,3 +105,9 @@ WHERE jsonSchema IN ('tableProfile', 'columnTest', 'tableTest');
DELETE FROM ingestion_pipeline_entity DELETE FROM ingestion_pipeline_entity
WHERE json_extract_path_text("json", 'pipelineType') = 'profiler'; WHERE json_extract_path_text("json", 'pipelineType') = 'profiler';
DELETE FROM role_entity;
DELETE FROM policy_entity;
DELETE FROM field_relationship WHERE fromType IN ('role', 'policy') OR toType IN ('role', 'policy');
DELETE FROM entity_relationship WHERE fromEntity IN ('role', 'policy') OR toEntity IN ('role', 'policy');
ALTER TABLE role_entity DROP COLUMN defaultRole;

View File

@ -1125,7 +1125,10 @@ public abstract class EntityRepository<T extends EntityInterface> {
this.original = original; this.original = original;
this.updated = updated; this.updated = updated;
this.operation = operation; this.operation = operation;
this.updatingUser = SubjectCache.getInstance().getSubjectContext(updated.getUpdatedBy()).getUser(); this.updatingUser =
updated.getUpdatedBy().equalsIgnoreCase("admin")
? new User().withName("admin").withIsAdmin(true)
: SubjectCache.getInstance().getSubjectContext(updated.getUpdatedBy()).getUser();
} }
/** Compare original and updated entities and perform updates. Update the entity version and track changes. */ /** Compare original and updated entities and perform updates. Update the entity version and track changes. */

View File

@ -328,21 +328,21 @@ public class TeamRepository extends EntityRepository<Team> {
String json = dao.findJsonByFqn(ORGANIZATION_NAME, Include.ALL); String json = dao.findJsonByFqn(ORGANIZATION_NAME, Include.ALL);
if (json == null) { if (json == null) {
LOG.debug("Organization {} is not initialized", ORGANIZATION_NAME); LOG.debug("Organization {} is not initialized", ORGANIZATION_NAME);
EntityReference organizationPolicy = Entity.getEntityReferenceByName(POLICY, "OrganizationPolicy", Include.ALL);
EntityReference dataConsumerRole = Entity.getEntityReferenceByName(ROLE, "DataConsumer", Include.ALL);
Team team =
new Team()
.withId(UUID.randomUUID())
.withName(ORGANIZATION_NAME)
.withDisplayName(ORGANIZATION_NAME)
.withDescription("Organization under which all the other team hierarchy is created")
.withTeamType(ORGANIZATION)
.withUpdatedBy("admin")
.withUpdatedAt(System.currentTimeMillis())
.withPolicies(new ArrayList<>(List.of(organizationPolicy)))
.withDefaultRoles(new ArrayList<>(List.of(dataConsumerRole)));
// Teams // Teams
try { try {
EntityReference organizationPolicy = Entity.getEntityReferenceByName(POLICY, "OrganizationPolicy", Include.ALL);
EntityReference dataConsumerRole = Entity.getEntityReferenceByName(ROLE, "DataConsumer", Include.ALL);
Team team =
new Team()
.withId(UUID.randomUUID())
.withName(ORGANIZATION_NAME)
.withDisplayName(ORGANIZATION_NAME)
.withDescription("Organization under which all the other team hierarchy is created")
.withTeamType(ORGANIZATION)
.withUpdatedBy("admin")
.withUpdatedAt(System.currentTimeMillis())
.withPolicies(new ArrayList<>(List.of(organizationPolicy)))
.withDefaultRoles(new ArrayList<>(List.of(dataConsumerRole)));
organization = create(null, team); organization = create(null, team);
LOG.info("Organization {}:{} is successfully initialized", ORGANIZATION_NAME, organization.getId()); LOG.info("Organization {}:{} is successfully initialized", ORGANIZATION_NAME, organization.getId());
} catch (Exception e) { } catch (Exception e) {

View File

@ -111,7 +111,7 @@ public class TypeResource extends EntityResource<Type, TypeRepository> {
} }
this.dao.createOrUpdate(null, type); this.dao.createOrUpdate(null, type);
this.dao.addToRegistry(type); this.dao.addToRegistry(type);
} catch (IOException e) { } catch (Exception e) {
LOG.error("Error loading type {}", type.getName(), e); LOG.error("Error loading type {}", type.getName(), e);
} }
}); });