如何删除发布后的项目(AppId)

需求

在使用携程Apollo配置中心的时候,有时候我们创建的项目仅仅用来测试,或者没用了。这时候我们想把他删除,会发现无法删除项目。

 

如何删除应用?

     根据官方描述

 

由于删除应用影响面较大,所以现在暂无删除应用功能。

此外,除了appId之外,其它app相关信息都能修改,所以不建议删除app。

如果确实需要删除应用的话,可以参照下面的sql手动删除数据库相关的表。

1.删除ApolloPortalDB中的数据

复制下面的sql内容,把第一行的appId从SampleApp改为实际要删除的appId,在ApolloPortalDB中执行即可。

 1 set @appId = 'SampleApp';
 2  
 3 Use `ApolloPortalDB`;
 4  
 5 update `App` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 6 update `AppNamespace` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 7 update `Favorite` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 8  
 9 # handle roles and permissions
10 create temporary table `PermissionIds` as select `Id` from `Permission` where (`TargetId` = @appId or `TargetId` like CONCAT(@appId, '+%'))  and `IsDeleted` = 0;
11 update `Permission` set `IsDeleted` = 1 where `Id` in (select `Id` from `PermissionIds`);
12 update `RolePermission` set `IsDeleted` = 1 where `PermissionId` in (select `Id` from `PermissionIds`);
13 drop temporary table `PermissionIds`;
14  
15 create temporary table `RoleIds` as select `Id` from `Role` where (`RoleName` = CONCAT('Master+', @appId) or `RoleName` like CONCAT('ModifyNamespace+', @appId, '+%') or `RoleName` like CONCAT('ReleaseNamespace+', @appId, '+%')) and `IsDeleted` = 0;
16 update `Role` set `IsDeleted` = 1 where `Id` in (select `Id` from `RoleIds`);
17 update `UserRole` set `IsDeleted` = 1 where `RoleId` in (select `Id` from `RoleIds`);
18 update `ConsumerRole` set `IsDeleted` = 1 where `RoleId` in (select `Id` from `RoleIds`);

2.删除ApolloConfigDB中的数据

  复制下面的sql内容,把第一行的appId从SampleApp改为实际要删除的appId,在AploolConfigDB中执行即可。

 1 set @appId = 'SampleApp';
 2  
 3 Use `ApolloConfigDB`;
 4  
 5 update `App` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 6 update `AppNamespace` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 7 update `Cluste r` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 8 update `Commit` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 9 update `GrayReleaseRule` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
10 update `Release` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
11 update `ReleaseHistory` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
12 delete from `Instance` where `AppId` = @appId;
13 delete from `InstanceConfig` where `ConfigAppId` = @appId;
14 delete from `ReleaseMessage` where `Message` like CONCAT(@appId, '+%');
15  
16 # handle namespaces and items
17 create temporary table `NamespaceIds` as select `Id` from `Namespace` where `AppId` = @appId and `IsDeleted` = 0;
18 update `Namespace` set `IsDeleted` = 1 where `Id` in (select `Id` from `NamespaceIds`);
19 update `Item` set `IsDeleted` = 1 where `NamespaceId` in (select `Id` from `NamespaceIds`);
20 delete from `NamespaceLock` where `NamespaceId` in (select `Id` from `NamespaceIds`);
21 drop temporary table `NamespaceIds`;

 

posted @ 2020-02-01 11:28  Randlly  阅读(530)  评论(0编辑  收藏  举报