apollo项目使用sql删除

set @appId = 'app-mayikt-weixin';
 
Use `ApolloPortalDB`;
 
update `App` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `AppNamespace` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `Favorite` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
 
# handle roles and permissions
create temporary table `PermissionIds` as select `Id` from `Permission` where (`TargetId` = @appId or `TargetId` like CONCAT(@appId, '+%'))  and `IsDeleted` = 0;
update `Permission` set `IsDeleted` = 1 where `Id` in (select `Id` from `PermissionIds`);
update `RolePermission` set `IsDeleted` = 1 where `PermissionId` in (select `Id` from `PermissionIds`);
drop temporary table `PermissionIds`;
 
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;
update `Role` set `IsDeleted` = 1 where `Id` in (select `Id` from `RoleIds`);
update `UserRole` set `IsDeleted` = 1 where `RoleId` in (select `Id` from `RoleIds`);
update `ConsumerRole` set `IsDeleted` = 1 where `RoleId` in (select `Id` from `RoleIds`);
drop temporary table `RoleIds`;


set @appId = 'app-mayikt-weixin';
 
Use `ApolloConfigDB`;
 
update `App` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `AppNamespace` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `Cluster` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `Commit` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `GrayReleaseRule` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `Release` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
update `ReleaseHistory` set `IsDeleted` = 1 where `AppId` = @appId and `IsDeleted` = 0;
delete from `Instance` where `AppId` = @appId;
delete from `InstanceConfig` where `ConfigAppId` = @appId;
delete from `ReleaseMessage` where `Message` like CONCAT(@appId, '+%');
 
# handle namespaces and items
create temporary table `NamespaceIds` as select `Id` from `Namespace` where `AppId` = @appId and `IsDeleted` = 0;
update `Namespace` set `IsDeleted` = 1 where `Id` in (select `Id` from `NamespaceIds`);
update `Item` set `IsDeleted` = 1 where `NamespaceId` in (select `Id` from `NamespaceIds`);
delete from `NamespaceLock` where `NamespaceId` in (select `Id` from `NamespaceIds`);
drop temporary table `NamespaceIds`;
 

转载于:https://my.oschina.net/u/3962987/blog/3063338

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值