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

Posted Randlly

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何删除发布后的项目(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`;

 

以上是关于如何删除发布后的项目(AppId)的主要内容,如果未能解决你的问题,请参考以下文章

如果在底部导航栏中选择了其他项目,如何删除 floatingActionButton 替换片段

Sleep() 方法后的代码片段没有被执行

比较 C# 中的字符串片段并从集合中删除项目

来自另一个片段的 Snackbar 回调

kotlin:如何在两个片段之间传递数据

如何从 URL 获取片段标识符(哈希 # 后的值)?