From 9378a66da6ddff0b1a5aaeeba598f47c34d64e53 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 29 May 2021 15:10:51 +0800 Subject: [PATCH 01/22] refactor: soft delete design, add `DeletedAt` column --- scripts/sql/apolloconfigdb.sql | 13 +++++++++++++ scripts/sql/apolloportaldb.sql | 11 +++++++++++ .../delta/v180-v190/apolloconfigdb-v180-v190.sql | 13 +++++++++++++ .../delta/v180-v190/apolloportaldb-v180-v190.sql | 12 ++++++++++++ 4 files changed, 49 insertions(+) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index 7274f7a086c..ff82f9cb00a 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -41,6 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -66,6 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -90,6 +92,7 @@ CREATE TABLE `Audit` ( `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -111,6 +114,7 @@ CREATE TABLE `Cluster` ( `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -136,6 +140,7 @@ CREATE TABLE `Commit` ( `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -162,6 +167,7 @@ CREATE TABLE `GrayReleaseRule` ( `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '灰度对应的release', `BranchStatus` tinyint(2) DEFAULT '1' COMMENT '灰度分支状态: 0:删除分支,1:正在使用的规则 2:全量发布', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -230,6 +236,7 @@ CREATE TABLE `Item` ( `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `LineNum` int(10) unsigned DEFAULT '0' COMMENT '行号', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -252,6 +259,7 @@ CREATE TABLE `Namespace` ( `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name', `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -277,6 +285,7 @@ CREATE TABLE `NamespaceLock` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', `IsDeleted` bit(1) DEFAULT b'0' COMMENT '软删除', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', PRIMARY KEY (`Id`), UNIQUE KEY `IX_NamespaceId` (`NamespaceId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) @@ -300,6 +309,7 @@ CREATE TABLE `Release` ( `Configurations` longtext NOT NULL COMMENT '发布配置', `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否废弃', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -327,6 +337,7 @@ CREATE TABLE `ReleaseHistory` ( `Operation` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '发布类型,0: 普通发布,1: 回滚,2: 灰度发布,3: 灰度规则更新,4: 灰度合并回主分支发布,5: 主分支发布灰度自动发布,6: 主分支回滚灰度自动发布,7: 放弃灰度', `OperationContext` longtext NOT NULL COMMENT '发布上下文信息', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -366,6 +377,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -386,6 +398,7 @@ CREATE TABLE `AccessKey` ( `Secret` varchar(128) NOT NULL DEFAULT '' COMMENT 'Secret', `IsEnabled` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: enabled, 0: disabled', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/apolloportaldb.sql b/scripts/sql/apolloportaldb.sql index 057d687bc52..68392ffdbca 100644 --- a/scripts/sql/apolloportaldb.sql +++ b/scripts/sql/apolloportaldb.sql @@ -41,6 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -66,6 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -92,6 +94,7 @@ CREATE TABLE `Consumer` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -132,6 +135,7 @@ CREATE TABLE `ConsumerRole` ( `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -155,6 +159,7 @@ CREATE TABLE `ConsumerToken` ( `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -175,6 +180,7 @@ CREATE TABLE `Favorite` ( `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -195,6 +201,7 @@ CREATE TABLE `Permission` ( `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -215,6 +222,7 @@ CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -236,6 +244,7 @@ CREATE TABLE `RolePermission` ( `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -259,6 +268,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -280,6 +290,7 @@ CREATE TABLE `UserRole` ( `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql index 34425039e72..887e82fe057 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql @@ -18,53 +18,66 @@ Use ApolloConfigDB; ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Audit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Cluster` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Commit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `GrayReleaseRule` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Item` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Namespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `NamespaceLock` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Release` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ReleaseHistory` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AccessKey` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql index e50688a545d..01d0ef0658b 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql @@ -18,52 +18,64 @@ Use ApolloPortalDB; ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Consumer` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerRole` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerToken` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Favorite` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Permission` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Role` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `RolePermission` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `UserRole` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Users` MODIFY COLUMN `Username` varchar(64) NOT NULL DEFAULT 'default' COMMENT '用户登录账户', ADD COLUMN `UserDisplayName` varchar(512) NOT NULL DEFAULT 'default' COMMENT '用户名称' AFTER `Password`; + UPDATE `Users` SET `UserDisplayName`=`Username` WHERE `UserDisplayName` = 'default'; ALTER TABLE `Users` From ba6b8362341593c0f4158210490a6cfa31e9475a Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 1 Aug 2021 01:08:32 +0800 Subject: [PATCH 02/22] refactor: replace deletedAt with DataChange_DeletedTime --- scripts/sql/apolloconfigdb.sql | 26 +++++++++---------- scripts/sql/apolloportaldb.sql | 22 ++++++++-------- .../v180-v190/apolloconfigdb-v180-v190.sql | 26 +++++++++---------- .../v180-v190/apolloportaldb-v180-v190.sql | 22 ++++++++-------- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index ff82f9cb00a..d6316032acf 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -41,7 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -67,7 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -92,7 +92,7 @@ CREATE TABLE `Audit` ( `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -114,7 +114,7 @@ CREATE TABLE `Cluster` ( `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -140,7 +140,7 @@ CREATE TABLE `Commit` ( `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -167,7 +167,7 @@ CREATE TABLE `GrayReleaseRule` ( `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '灰度对应的release', `BranchStatus` tinyint(2) DEFAULT '1' COMMENT '灰度分支状态: 0:删除分支,1:正在使用的规则 2:全量发布', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -236,7 +236,7 @@ CREATE TABLE `Item` ( `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `LineNum` int(10) unsigned DEFAULT '0' COMMENT '行号', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -259,7 +259,7 @@ CREATE TABLE `Namespace` ( `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name', `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -285,7 +285,7 @@ CREATE TABLE `NamespaceLock` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', `IsDeleted` bit(1) DEFAULT b'0' COMMENT '软删除', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', PRIMARY KEY (`Id`), UNIQUE KEY `IX_NamespaceId` (`NamespaceId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) @@ -309,7 +309,7 @@ CREATE TABLE `Release` ( `Configurations` longtext NOT NULL COMMENT '发布配置', `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否废弃', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -337,7 +337,7 @@ CREATE TABLE `ReleaseHistory` ( `Operation` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '发布类型,0: 普通发布,1: 回滚,2: 灰度发布,3: 灰度规则更新,4: 灰度合并回主分支发布,5: 主分支发布灰度自动发布,6: 主分支回滚灰度自动发布,7: 放弃灰度', `OperationContext` longtext NOT NULL COMMENT '发布上下文信息', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -377,7 +377,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -398,7 +398,7 @@ CREATE TABLE `AccessKey` ( `Secret` varchar(128) NOT NULL DEFAULT '' COMMENT 'Secret', `IsEnabled` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: enabled, 0: disabled', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/apolloportaldb.sql b/scripts/sql/apolloportaldb.sql index 68392ffdbca..dbb163adf38 100644 --- a/scripts/sql/apolloportaldb.sql +++ b/scripts/sql/apolloportaldb.sql @@ -41,7 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -67,7 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -94,7 +94,7 @@ CREATE TABLE `Consumer` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -135,7 +135,7 @@ CREATE TABLE `ConsumerRole` ( `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -159,7 +159,7 @@ CREATE TABLE `ConsumerToken` ( `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -180,7 +180,7 @@ CREATE TABLE `Favorite` ( `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -201,7 +201,7 @@ CREATE TABLE `Permission` ( `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -222,7 +222,7 @@ CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -244,7 +244,7 @@ CREATE TABLE `RolePermission` ( `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -268,7 +268,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -290,7 +290,7 @@ CREATE TABLE `UserRole` ( `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', + `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql index 887e82fe057..688fdb675bd 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql @@ -18,66 +18,66 @@ Use ApolloConfigDB; ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Audit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Cluster` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Commit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `GrayReleaseRule` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Item` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Namespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `NamespaceLock` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Release` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ReleaseHistory` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AccessKey` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql index 01d0ef0658b..92ac3b01ad3 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql @@ -18,57 +18,57 @@ Use ApolloPortalDB; ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Consumer` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerRole` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerToken` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Favorite` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Permission` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Role` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `RolePermission` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `UserRole` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; From a3c2ee7e6b503427754da40d2d813a09b13bdfb0 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 1 Aug 2021 01:31:58 +0800 Subject: [PATCH 03/22] refactor: add DataChange_DeletedTime for BaseEntity, update all @SQLDelete --- .../apollo/biz/entity/AccessKey.java | 2 +- .../framework/apollo/biz/entity/Audit.java | 2 +- .../framework/apollo/biz/entity/Cluster.java | 2 +- .../framework/apollo/biz/entity/Commit.java | 2 +- .../apollo/biz/entity/GrayReleaseRule.java | 2 +- .../framework/apollo/biz/entity/Item.java | 2 +- .../apollo/biz/entity/Namespace.java | 2 +- .../apollo/biz/entity/Privilege.java | 2 +- .../framework/apollo/biz/entity/Release.java | 2 +- .../apollo/biz/entity/ReleaseHistory.java | 2 +- .../apollo/biz/entity/ServerConfig.java | 2 +- .../framework/apollo/common/entity/App.java | 2 +- .../apollo/common/entity/AppNamespace.java | 2 +- .../apollo/common/entity/BaseEntity.java | 58 ++++++++++++------- .../apollo/openapi/entity/Consumer.java | 2 +- .../apollo/openapi/entity/ConsumerRole.java | 2 +- .../apollo/openapi/entity/ConsumerToken.java | 2 +- .../apollo/portal/entity/po/Favorite.java | 2 +- .../apollo/portal/entity/po/Permission.java | 2 +- .../apollo/portal/entity/po/Role.java | 2 +- .../portal/entity/po/RolePermission.java | 2 +- .../apollo/portal/entity/po/ServerConfig.java | 2 +- .../apollo/portal/entity/po/UserRole.java | 2 +- 23 files changed, 59 insertions(+), 43 deletions(-) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java index f5c5b204e8e..c536a644ca2 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java @@ -26,7 +26,7 @@ @Entity @Table(name = "AccessKey") -@SQLDelete(sql = "Update AccessKey set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update AccessKey set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class AccessKey extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java index 7505943e298..30ca8ff617c 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Audit") -@SQLDelete(sql = "Update Audit set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Audit set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Audit extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java index b8ee153733d..602e63a2ce9 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Cluster") -@SQLDelete(sql = "Update Cluster set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Cluster set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Cluster extends BaseEntity implements Comparable { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java index c15935fa0c2..c46952f3913 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java @@ -28,7 +28,7 @@ @Entity @Table(name = "Commit") -@SQLDelete(sql = "Update Commit set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Commit set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Commit extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java index 4ea35c46f38..221e1848ac5 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java @@ -27,7 +27,7 @@ @Entity @Table(name = "GrayReleaseRule") -@SQLDelete(sql = "Update GrayReleaseRule set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update GrayReleaseRule set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class GrayReleaseRule extends BaseEntity{ diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java index 23ee13c997d..f3629b5145e 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java @@ -28,7 +28,7 @@ @Entity @Table(name = "Item") -@SQLDelete(sql = "Update Item set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Item set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Item extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java index 59c79cc8cdb..0ff754fd041 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Namespace") -@SQLDelete(sql = "Update Namespace set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Namespace set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Namespace extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java index 2de0a42759b..cc8c308cad6 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Privilege") -@SQLDelete(sql = "Update Privilege set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Privilege set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Privilege extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java index 8fe14ca46db..b060a5fdf7a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java @@ -31,7 +31,7 @@ */ @Entity @Table(name = "Release") -@SQLDelete(sql = "Update Release set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Release set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Release extends BaseEntity { @Column(name = "ReleaseKey", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java index 713b74a1a1b..8a3fdd3147d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ReleaseHistory") -@SQLDelete(sql = "Update ReleaseHistory set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update ReleaseHistory set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ReleaseHistory extends BaseEntity { @Column(name = "AppId", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java index acf6a15c4f2..d7ce2de05cf 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ServerConfig") -@SQLDelete(sql = "Update ServerConfig set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ServerConfig extends BaseEntity { @Column(name = "Key", nullable = false) diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java index eed83acd1e1..a94641b0208 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java @@ -28,7 +28,7 @@ @Entity @Table(name = "App") -@SQLDelete(sql = "Update App set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update App set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class App extends BaseEntity { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java index 8d6db2fbdda..1be00dfa18a 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java @@ -31,7 +31,7 @@ @Entity @Table(name = "AppNamespace") -@SQLDelete(sql = "Update AppNamespace set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update AppNamespace set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class AppNamespace extends BaseEntity { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java index 99ca98776c2..a375ee96b46 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java @@ -44,6 +44,9 @@ public abstract class BaseEntity { @Column(name = "IsDeleted", columnDefinition = "Bit default '0'") protected boolean isDeleted = false; + @Column(name = "DataChange_DeletedTime") + private Date dataChangeDeletedTime; + @Column(name = "DataChange_CreatedBy", nullable = false) private String dataChangeCreatedBy; @@ -56,52 +59,62 @@ public abstract class BaseEntity { @Column(name = "DataChange_LastTime") private Date dataChangeLastModifiedTime; - public String getDataChangeCreatedBy() { - return dataChangeCreatedBy; + public long getId() { + return id; } - public Date getDataChangeCreatedTime() { - return dataChangeCreatedTime; + public void setId(long id) { + this.id = id; } - public String getDataChangeLastModifiedBy() { - return dataChangeLastModifiedBy; + public boolean isDeleted() { + return isDeleted; } - public Date getDataChangeLastModifiedTime() { - return dataChangeLastModifiedTime; + public void setDeleted(boolean deleted) { + isDeleted = deleted; + // also update the deletedTime + this.dataChangeDeletedTime = new Date(); } - public long getId() { - return id; + public Date getDataChangeDeletedTime() { + return dataChangeDeletedTime; } - public boolean isDeleted() { - return isDeleted; + public void setDataChangeDeletedTime(Date dataChangeDeletedTime) { + this.dataChangeDeletedTime = dataChangeDeletedTime; + } + + public String getDataChangeCreatedBy() { + return dataChangeCreatedBy; } public void setDataChangeCreatedBy(String dataChangeCreatedBy) { this.dataChangeCreatedBy = dataChangeCreatedBy; } + public Date getDataChangeCreatedTime() { + return dataChangeCreatedTime; + } + public void setDataChangeCreatedTime(Date dataChangeCreatedTime) { this.dataChangeCreatedTime = dataChangeCreatedTime; } - public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) { - this.dataChangeLastModifiedBy = dataChangeLastModifiedBy; + public String getDataChangeLastModifiedBy() { + return dataChangeLastModifiedBy; } - public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) { - this.dataChangeLastModifiedTime = dataChangeLastModifiedTime; + public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) { + this.dataChangeLastModifiedBy = dataChangeLastModifiedBy; } - public void setDeleted(boolean deleted) { - isDeleted = deleted; + public Date getDataChangeLastModifiedTime() { + return dataChangeLastModifiedTime; } - public void setId(long id) { - this.id = id; + public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) { + this.dataChangeLastModifiedTime = dataChangeLastModifiedTime; } @PrePersist @@ -121,7 +134,10 @@ protected void preUpdate() { @PreRemove protected void preRemove() { - this.dataChangeLastModifiedTime = new Date(); + Date date = new Date(); + this.dataChangeLastModifiedTime = date; + this.dataChangeDeletedTime = date; + this.isDeleted = true; } protected ToStringHelper toStringHelper() { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java index fe63981f1fa..cb7d8ed6edf 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Consumer") -@SQLDelete(sql = "Update Consumer set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Consumer set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Consumer extends BaseEntity { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java index ec9f6927a6b..abd56825c38 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ConsumerRole") -@SQLDelete(sql = "Update ConsumerRole set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update ConsumerRole set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ConsumerRole extends BaseEntity { @Column(name = "ConsumerId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java index 2d33dfe5655..f49ddef32f0 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java @@ -32,7 +32,7 @@ */ @Entity @Table(name = "ConsumerToken") -@SQLDelete(sql = "Update ConsumerToken set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update ConsumerToken set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ConsumerToken extends BaseEntity { @Column(name = "ConsumerId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java index 34ae7fd446b..c035f7cf5b2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Favorite") -@SQLDelete(sql = "Update Favorite set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Favorite set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Favorite extends BaseEntity { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java index 6af224ecc21..2814c556a71 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Permission") -@SQLDelete(sql = "Update Permission set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Permission set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Permission extends BaseEntity { @Column(name = "PermissionType", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java index 9313cee10f2..2c62b0bbb36 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Role") -@SQLDelete(sql = "Update Role set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update Role set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Role extends BaseEntity { @Column(name = "RoleName", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java index fd9d769e266..7e37aec52f8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "RolePermission") -@SQLDelete(sql = "Update RolePermission set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update RolePermission set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class RolePermission extends BaseEntity { @Column(name = "RoleId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java index 2c59483f0b0..33fa19dca80 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java @@ -31,7 +31,7 @@ */ @Entity @Table(name = "ServerConfig") -@SQLDelete(sql = "Update ServerConfig set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ServerConfig extends BaseEntity { @NotBlank(message = "ServerConfig.Key cannot be blank") diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java index 12b30d1e573..093d2104fcc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "UserRole") -@SQLDelete(sql = "Update UserRole set isDeleted = 1 where id = ?") +@SQLDelete(sql = "Update UserRole set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class UserRole extends BaseEntity { @Column(name = "UserId", nullable = false) From ed541dfcd684fb095463f1dea2c9f23d1c7bc3dc Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 1 Aug 2021 17:24:15 +0800 Subject: [PATCH 04/22] refactor: add deletedAt column base on seconds --- scripts/sql/apolloconfigdb.sql | 26 +++++++++---------- scripts/sql/apolloportaldb.sql | 22 ++++++++-------- .../v180-v190/apolloconfigdb-v180-v190.sql | 26 +++++++++---------- .../v180-v190/apolloportaldb-v180-v190.sql | 22 ++++++++-------- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index d6316032acf..2db7dfe467d 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -41,7 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -67,7 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -92,7 +92,7 @@ CREATE TABLE `Audit` ( `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -114,7 +114,7 @@ CREATE TABLE `Cluster` ( `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -140,7 +140,7 @@ CREATE TABLE `Commit` ( `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -167,7 +167,7 @@ CREATE TABLE `GrayReleaseRule` ( `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '灰度对应的release', `BranchStatus` tinyint(2) DEFAULT '1' COMMENT '灰度分支状态: 0:删除分支,1:正在使用的规则 2:全量发布', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -236,7 +236,7 @@ CREATE TABLE `Item` ( `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `LineNum` int(10) unsigned DEFAULT '0' COMMENT '行号', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -259,7 +259,7 @@ CREATE TABLE `Namespace` ( `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name', `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -285,7 +285,7 @@ CREATE TABLE `NamespaceLock` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', `IsDeleted` bit(1) DEFAULT b'0' COMMENT '软删除', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', PRIMARY KEY (`Id`), UNIQUE KEY `IX_NamespaceId` (`NamespaceId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) @@ -309,7 +309,7 @@ CREATE TABLE `Release` ( `Configurations` longtext NOT NULL COMMENT '发布配置', `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否废弃', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -337,7 +337,7 @@ CREATE TABLE `ReleaseHistory` ( `Operation` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '发布类型,0: 普通发布,1: 回滚,2: 灰度发布,3: 灰度规则更新,4: 灰度合并回主分支发布,5: 主分支发布灰度自动发布,6: 主分支回滚灰度自动发布,7: 放弃灰度', `OperationContext` longtext NOT NULL COMMENT '发布上下文信息', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -377,7 +377,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -398,7 +398,7 @@ CREATE TABLE `AccessKey` ( `Secret` varchar(128) NOT NULL DEFAULT '' COMMENT 'Secret', `IsEnabled` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: enabled, 0: disabled', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/apolloportaldb.sql b/scripts/sql/apolloportaldb.sql index dbb163adf38..9e356102e46 100644 --- a/scripts/sql/apolloportaldb.sql +++ b/scripts/sql/apolloportaldb.sql @@ -41,7 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -67,7 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -94,7 +94,7 @@ CREATE TABLE `Consumer` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -135,7 +135,7 @@ CREATE TABLE `ConsumerRole` ( `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -159,7 +159,7 @@ CREATE TABLE `ConsumerToken` ( `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -180,7 +180,7 @@ CREATE TABLE `Favorite` ( `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -201,7 +201,7 @@ CREATE TABLE `Permission` ( `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -222,7 +222,7 @@ CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -244,7 +244,7 @@ CREATE TABLE `RolePermission` ( `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -268,7 +268,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -290,7 +290,7 @@ CREATE TABLE `UserRole` ( `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql index 688fdb675bd..d409fd119ea 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql @@ -18,66 +18,66 @@ Use ApolloConfigDB; ALTER TABLE `App` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Audit` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Cluster` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Commit` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `GrayReleaseRule` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Item` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Namespace` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `NamespaceLock` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Release` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ReleaseHistory` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AccessKey` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql index 92ac3b01ad3..4044a0c16fb 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql @@ -18,57 +18,57 @@ Use ApolloPortalDB; ALTER TABLE `App` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Consumer` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerRole` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerToken` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Favorite` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Permission` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Role` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `RolePermission` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `UserRole` - ADD COLUMN `DataChange_DeletedTime` timestamp NULL COMMENT 'Deleted Time' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; From 13b897711b1de2ef64062a0b0688b9ef468b8ce6 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 1 Aug 2021 17:52:40 +0800 Subject: [PATCH 05/22] refactor: add DeletedAt field for BaseEntity, update all soft delete logic with UNXI_TIMESTAMP() --- .../apollo/biz/entity/AccessKey.java | 2 +- .../framework/apollo/biz/entity/Audit.java | 2 +- .../framework/apollo/biz/entity/Cluster.java | 2 +- .../framework/apollo/biz/entity/Commit.java | 2 +- .../apollo/biz/entity/GrayReleaseRule.java | 2 +- .../framework/apollo/biz/entity/Item.java | 2 +- .../apollo/biz/entity/Namespace.java | 2 +- .../apollo/biz/entity/Privilege.java | 2 +- .../framework/apollo/biz/entity/Release.java | 2 +- .../apollo/biz/entity/ReleaseHistory.java | 2 +- .../apollo/biz/entity/ServerConfig.java | 2 +- .../repository/AppNamespaceRepository.java | 4 ++-- .../biz/repository/CommitRepository.java | 2 +- .../apollo/biz/repository/ItemRepository.java | 2 +- .../biz/repository/NamespaceRepository.java | 2 +- .../repository/ReleaseHistoryRepository.java | 2 +- .../biz/repository/ReleaseRepository.java | 2 +- .../framework/apollo/common/entity/App.java | 2 +- .../apollo/common/entity/AppNamespace.java | 2 +- .../apollo/common/entity/BaseEntity.java | 22 +++++++++---------- .../apollo/openapi/entity/Consumer.java | 2 +- .../apollo/openapi/entity/ConsumerRole.java | 2 +- .../apollo/openapi/entity/ConsumerToken.java | 2 +- .../repository/ConsumerRoleRepository.java | 2 +- .../apollo/portal/entity/po/Favorite.java | 2 +- .../apollo/portal/entity/po/Permission.java | 2 +- .../apollo/portal/entity/po/Role.java | 2 +- .../portal/entity/po/RolePermission.java | 2 +- .../apollo/portal/entity/po/ServerConfig.java | 2 +- .../apollo/portal/entity/po/UserRole.java | 2 +- .../repository/AppNamespaceRepository.java | 4 ++-- .../portal/repository/AppRepository.java | 2 +- .../portal/repository/FavoriteRepository.java | 2 +- .../repository/PermissionRepository.java | 2 +- .../repository/RolePermissionRepository.java | 2 +- .../portal/repository/RoleRepository.java | 2 +- .../portal/repository/UserRoleRepository.java | 2 +- 37 files changed, 48 insertions(+), 50 deletions(-) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java index c536a644ca2..168ea24b7f9 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java @@ -26,7 +26,7 @@ @Entity @Table(name = "AccessKey") -@SQLDelete(sql = "Update AccessKey set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update AccessKey set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class AccessKey extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java index 30ca8ff617c..91a0633f995 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Audit") -@SQLDelete(sql = "Update Audit set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Audit set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Audit extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java index 602e63a2ce9..ec1c5570cd6 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Cluster") -@SQLDelete(sql = "Update Cluster set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Cluster set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Cluster extends BaseEntity implements Comparable { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java index c46952f3913..64a85600522 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java @@ -28,7 +28,7 @@ @Entity @Table(name = "Commit") -@SQLDelete(sql = "Update Commit set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Commit set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Commit extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java index 221e1848ac5..40c4fc696a7 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java @@ -27,7 +27,7 @@ @Entity @Table(name = "GrayReleaseRule") -@SQLDelete(sql = "Update GrayReleaseRule set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update GrayReleaseRule set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class GrayReleaseRule extends BaseEntity{ diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java index f3629b5145e..320c7aadfd8 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java @@ -28,7 +28,7 @@ @Entity @Table(name = "Item") -@SQLDelete(sql = "Update Item set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Item set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Item extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java index 0ff754fd041..686e645ae61 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Namespace") -@SQLDelete(sql = "Update Namespace set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Namespace set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Namespace extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java index cc8c308cad6..89b744d4f62 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Privilege") -@SQLDelete(sql = "Update Privilege set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Privilege set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Privilege extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java index b060a5fdf7a..695b9380876 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java @@ -31,7 +31,7 @@ */ @Entity @Table(name = "Release") -@SQLDelete(sql = "Update Release set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Release set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Release extends BaseEntity { @Column(name = "ReleaseKey", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java index 8a3fdd3147d..3b6a4f0e3cb 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ReleaseHistory") -@SQLDelete(sql = "Update ReleaseHistory set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ReleaseHistory set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ReleaseHistory extends BaseEntity { @Column(name = "AppId", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java index d7ce2de05cf..bf8d0767d55 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ServerConfig") -@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ServerConfig extends BaseEntity { @Column(name = "Key", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java index 9de3b134fca..f70fd40273c 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java @@ -43,10 +43,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository findFirst500ByIdGreaterThanOrderByIdAsc(long id); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") int batchDeleteByAppId(String appId, String operator); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") int delete(String appId, String namespaceName, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java index d77bfd0a194..e8c88bf68d8 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java @@ -35,7 +35,7 @@ List findByAppIdAndClusterNameAndNamespaceNameAndDataChangeLastModifiedT String appId, String clusterName, String namespaceName, Date dataChangeLastModifiedTime, Pageable pageable); @Modifying - @Query("update Commit set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update Commit set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") int batchDelete(String appId, String clusterName, String namespaceName, String operator); List findByAppIdAndClusterNameAndNamespaceNameAndChangeSetsLikeOrderByIdDesc(String appId, String clusterName, String namespaceName,String changeSets, Pageable page); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java index c956a832890..148c0971e0d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java @@ -42,7 +42,7 @@ public interface ItemRepository extends PagingAndSortingRepository { Item findFirst1ByNamespaceIdOrderByLineNumDesc(Long namespaceId); @Modifying - @Query("update Item set isdeleted=1,DataChange_LastModifiedBy = ?2 where namespaceId = ?1") + @Query("update Item set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 where namespaceId = ?1") int deleteByNamespaceId(long namespaceId, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java index 5fe0cbd3465..b1c82de7a5d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java @@ -33,7 +33,7 @@ public interface NamespaceRepository extends PagingAndSortingRepository findByAppIdAndNamespaceNameOrderByIdAsc(String appId, String namespaceName); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java index 8e0efeb7edb..6c460434fff 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java @@ -39,7 +39,7 @@ Page findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(Stri Page findByReleaseIdAndOperationInOrderByIdDesc(long releaseId, Set operations, Pageable pageable); @Modifying - @Query("update ReleaseHistory set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") int batchDelete(String appId, String clusterName, String namespaceName, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java index a6d9472b308..e1c3bf42bd1 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java @@ -48,7 +48,7 @@ Release findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderBy List findByIdIn(Set releaseIds); @Modifying - @Query("update Release set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update Release set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") int batchDelete(String appId, String clusterName, String namespaceName, String operator); // For release history conversion program, need to delete after conversion it done diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java index a94641b0208..19fb62c5303 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java @@ -28,7 +28,7 @@ @Entity @Table(name = "App") -@SQLDelete(sql = "Update App set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update App set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class App extends BaseEntity { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java index 1be00dfa18a..9279f67594e 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java @@ -31,7 +31,7 @@ @Entity @Table(name = "AppNamespace") -@SQLDelete(sql = "Update AppNamespace set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update AppNamespace set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class AppNamespace extends BaseEntity { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java index a375ee96b46..3373342c373 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java @@ -19,6 +19,7 @@ import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; +import java.time.Instant; import java.util.Date; import javax.persistence.Column; @@ -44,8 +45,8 @@ public abstract class BaseEntity { @Column(name = "IsDeleted", columnDefinition = "Bit default '0'") protected boolean isDeleted = false; - @Column(name = "DataChange_DeletedTime") - private Date dataChangeDeletedTime; + @Column(name = "DeletedAt") + protected long deletedAt; @Column(name = "DataChange_CreatedBy", nullable = false) private String dataChangeCreatedBy; @@ -73,16 +74,16 @@ public boolean isDeleted() { public void setDeleted(boolean deleted) { isDeleted = deleted; - // also update the deletedTime - this.dataChangeDeletedTime = new Date(); + // also set deletedAt value as epoch second + this.deletedAt = Instant.now().getEpochSecond(); } - public Date getDataChangeDeletedTime() { - return dataChangeDeletedTime; + public long getDeletedAt() { + return deletedAt; } - public void setDataChangeDeletedTime(Date dataChangeDeletedTime) { - this.dataChangeDeletedTime = dataChangeDeletedTime; + public void setDeletedAt(long deletedAt) { + this.deletedAt = deletedAt; } public String getDataChangeCreatedBy() { @@ -134,10 +135,7 @@ protected void preUpdate() { @PreRemove protected void preRemove() { - Date date = new Date(); - this.dataChangeLastModifiedTime = date; - this.dataChangeDeletedTime = date; - this.isDeleted = true; + this.dataChangeLastModifiedTime = new Date(); } protected ToStringHelper toStringHelper() { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java index cb7d8ed6edf..694d34955d9 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Consumer") -@SQLDelete(sql = "Update Consumer set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Consumer set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Consumer extends BaseEntity { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java index abd56825c38..e88561a7fa8 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ConsumerRole") -@SQLDelete(sql = "Update ConsumerRole set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ConsumerRole set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ConsumerRole extends BaseEntity { @Column(name = "ConsumerId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java index f49ddef32f0..75071827ae6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java @@ -32,7 +32,7 @@ */ @Entity @Table(name = "ConsumerToken") -@SQLDelete(sql = "Update ConsumerToken set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ConsumerToken set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ConsumerToken extends BaseEntity { @Column(name = "ConsumerId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java index 0791629e130..aa084cd48d2 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java @@ -43,6 +43,6 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository roleIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java index c035f7cf5b2..7a172c6d36c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Favorite") -@SQLDelete(sql = "Update Favorite set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Favorite set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Favorite extends BaseEntity { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java index 2814c556a71..74d896007b1 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Permission") -@SQLDelete(sql = "Update Permission set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Permission set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Permission extends BaseEntity { @Column(name = "PermissionType", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java index 2c62b0bbb36..45893386391 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Role") -@SQLDelete(sql = "Update Role set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Role set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class Role extends BaseEntity { @Column(name = "RoleName", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java index 7e37aec52f8..498d4d9e574 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "RolePermission") -@SQLDelete(sql = "Update RolePermission set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update RolePermission set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class RolePermission extends BaseEntity { @Column(name = "RoleId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java index 33fa19dca80..d1b862f8b83 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java @@ -31,7 +31,7 @@ */ @Entity @Table(name = "ServerConfig") -@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class ServerConfig extends BaseEntity { @NotBlank(message = "ServerConfig.Key cannot be blank") diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java index 093d2104fcc..2a27e872938 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "UserRole") -@SQLDelete(sql = "Update UserRole set IsDeleted = 1, DataChange_DeletedTime = CURRENT_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update UserRole set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") @Where(clause = "isDeleted = 0") public class UserRole extends BaseEntity { @Column(name = "UserId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java index caa30ffd096..d347e863ba9 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java @@ -35,10 +35,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository findByAppId(String appId); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy=?2 WHERE AppId=?1") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy=?2 WHERE AppId=?1") int batchDeleteByAppId(String appId, String operator); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted=1,DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") int delete(String appId, String namespaceName, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java index 6a09696dbf6..5386350be44 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java @@ -41,6 +41,6 @@ public interface AppRepository extends PagingAndSortingRepository { Page findByAppIdContainingOrNameContaining(String appId, String name, Pageable pageable); @Modifying - @Query("UPDATE App SET IsDeleted=1,DataChange_LastModifiedBy = ?2 WHERE AppId=?1") + @Query("UPDATE App SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") int deleteApp(String appId, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java index 2fe5294b26a..a6afc429eff 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java @@ -36,6 +36,6 @@ public interface FavoriteRepository extends PagingAndSortingRepository findByPermissionTypeInAndTargetId(Collection permission List findPermissionIdsByAppIdAndNamespace(String appId, String namespaceName); @Modifying - @Query("UPDATE Permission SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE Id in ?1") + @Query("UPDATE Permission SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") Integer batchDelete(List permissionIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java index c07b817ee5b..1b87b0d130a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java @@ -36,6 +36,6 @@ public interface RolePermissionRepository extends PagingAndSortingRepository findByRoleIdIn(Collection roleId); @Modifying - @Query("UPDATE RolePermission SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") + @Query("UPDATE RolePermission SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") Integer batchDeleteByPermissionIds(List permissionIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java index 31561fde97f..03220fae09c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java @@ -43,6 +43,6 @@ public interface RoleRepository extends PagingAndSortingRepository { List findRoleIdsByAppIdAndNamespace(String appId, String namespaceName); @Modifying - @Query("UPDATE Role SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE Id in ?1") + @Query("UPDATE Role SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") Integer batchDelete(List roleIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java index ca8fb1a507d..043a5f68afc 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java @@ -45,7 +45,7 @@ public interface UserRoleRepository extends PagingAndSortingRepository findByUserIdInAndRoleId(Collection userId, long roleId); @Modifying - @Query("UPDATE UserRole SET IsDeleted=1, DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1") + @Query("UPDATE UserRole SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1") Integer batchDeleteByRoleIds(List roleIds, String operator); } From 75e6db1319e78afa01224a731b4c743d1efe47ee Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 1 Aug 2021 22:55:16 +0800 Subject: [PATCH 06/22] =?UTF-8?q?refactor:=20add=20DML=20for=20each=20tabl?= =?UTF-8?q?e=20and=20add=20UNIQUE=20INDEX=EF=BC=88WIP=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apolloconfigdb-v180-v190-after.sql | 34 +++++++++++++++++++ .../apolloportaldb-v180-v190-after.sql | 32 +++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql create mode 100644 scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql new file mode 100644 index 00000000000..2e6450f79fa --- /dev/null +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql @@ -0,0 +1,34 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo config db from v1.8.0 to v1.9.0 + +Use ApolloConfigDB; + +UPDATE `App` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AppNamespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Audit` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Cluster` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Commit` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `GrayReleaseRule` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Item` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Namespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `NamespaceLock` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Release` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ReleaseHistory` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ServerConfig` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AccessKey` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; + +-- TODO: add UNIQUE CONSTRAINT INDEX for each table \ No newline at end of file diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql new file mode 100644 index 00000000000..42c9b44347b --- /dev/null +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql @@ -0,0 +1,32 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo portal db from v1.8.0 to v1.9.0 + +Use ApolloPortalDB; + +UPDATE `App` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AppNamespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Consumer` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ConsumerRole` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ConsumerToken` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Favorite` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Permission` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Role` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `RolePermission` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ServerConfig` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `UserRole` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; + +-- TODO: add UNIQUE CONSTRAINT INDEX for each table \ No newline at end of file From 066d30a15aa4e36e178ef23f3d72847457ad190c Mon Sep 17 00:00:00 2001 From: nisiyong Date: Wed, 4 Aug 2021 13:44:03 +0800 Subject: [PATCH 07/22] refactor: update Delete timestamp based on milliseconds --- .../apollo/biz/entity/AccessKey.java | 2 +- .../framework/apollo/biz/entity/Audit.java | 2 +- .../framework/apollo/biz/entity/Cluster.java | 2 +- .../framework/apollo/biz/entity/Commit.java | 2 +- .../apollo/biz/entity/GrayReleaseRule.java | 2 +- .../framework/apollo/biz/entity/Item.java | 2 +- .../apollo/biz/entity/Namespace.java | 2 +- .../apollo/biz/entity/Privilege.java | 2 +- .../framework/apollo/biz/entity/Release.java | 2 +- .../apollo/biz/entity/ReleaseHistory.java | 2 +- .../apollo/biz/entity/ServerConfig.java | 2 +- .../repository/AppNamespaceRepository.java | 4 +-- .../biz/repository/CommitRepository.java | 2 +- .../apollo/biz/repository/ItemRepository.java | 2 +- .../biz/repository/NamespaceRepository.java | 2 +- .../repository/ReleaseHistoryRepository.java | 2 +- .../biz/repository/ReleaseRepository.java | 2 +- .../framework/apollo/common/entity/App.java | 2 +- .../apollo/common/entity/AppNamespace.java | 2 +- .../apollo/common/entity/BaseEntity.java | 4 +-- .../apollo/openapi/entity/Consumer.java | 2 +- .../apollo/openapi/entity/ConsumerRole.java | 2 +- .../apollo/openapi/entity/ConsumerToken.java | 2 +- .../repository/ConsumerRoleRepository.java | 2 +- .../apollo/portal/entity/po/Favorite.java | 2 +- .../apollo/portal/entity/po/Permission.java | 2 +- .../apollo/portal/entity/po/Role.java | 2 +- .../portal/entity/po/RolePermission.java | 2 +- .../apollo/portal/entity/po/ServerConfig.java | 2 +- .../apollo/portal/entity/po/UserRole.java | 2 +- .../repository/AppNamespaceRepository.java | 4 +-- .../portal/repository/AppRepository.java | 2 +- .../portal/repository/FavoriteRepository.java | 2 +- .../repository/PermissionRepository.java | 2 +- .../repository/RolePermissionRepository.java | 2 +- .../portal/repository/RoleRepository.java | 2 +- .../portal/repository/UserRoleRepository.java | 2 +- scripts/sql/apolloconfigdb.sql | 26 +++++++++---------- scripts/sql/apolloportaldb.sql | 22 ++++++++-------- .../v180-v190/apolloconfigdb-v180-v190.sql | 26 +++++++++---------- .../v180-v190/apolloportaldb-v180-v190.sql | 22 ++++++++-------- 41 files changed, 88 insertions(+), 88 deletions(-) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java index 168ea24b7f9..260c91f071a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java @@ -26,7 +26,7 @@ @Entity @Table(name = "AccessKey") -@SQLDelete(sql = "Update AccessKey set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update AccessKey set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class AccessKey extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java index 91a0633f995..8bd08ff14b7 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Audit") -@SQLDelete(sql = "Update Audit set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Audit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Audit extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java index ec1c5570cd6..8be52d30508 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Cluster") -@SQLDelete(sql = "Update Cluster set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Cluster set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Cluster extends BaseEntity implements Comparable { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java index 64a85600522..0dd5e2cc0f9 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java @@ -28,7 +28,7 @@ @Entity @Table(name = "Commit") -@SQLDelete(sql = "Update Commit set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Commit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Commit extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java index 40c4fc696a7..4b8e10f7baf 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java @@ -27,7 +27,7 @@ @Entity @Table(name = "GrayReleaseRule") -@SQLDelete(sql = "Update GrayReleaseRule set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update GrayReleaseRule set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class GrayReleaseRule extends BaseEntity{ diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java index 320c7aadfd8..c30623908bd 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java @@ -28,7 +28,7 @@ @Entity @Table(name = "Item") -@SQLDelete(sql = "Update Item set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Item set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Item extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java index 686e645ae61..869e582d104 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Namespace") -@SQLDelete(sql = "Update Namespace set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Namespace set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Namespace extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java index 89b744d4f62..baa6f693ea3 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Privilege") -@SQLDelete(sql = "Update Privilege set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Privilege set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Privilege extends BaseEntity { diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java index 695b9380876..d6099279c40 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java @@ -31,7 +31,7 @@ */ @Entity @Table(name = "Release") -@SQLDelete(sql = "Update Release set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Release set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Release extends BaseEntity { @Column(name = "ReleaseKey", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java index 3b6a4f0e3cb..e3a13f13de3 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ReleaseHistory") -@SQLDelete(sql = "Update ReleaseHistory set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ReleaseHistory set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class ReleaseHistory extends BaseEntity { @Column(name = "AppId", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java index bf8d0767d55..2b4a8cfd044 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ServerConfig") -@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class ServerConfig extends BaseEntity { @Column(name = "Key", nullable = false) diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java index f70fd40273c..46e783a6a9d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java @@ -43,10 +43,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository findFirst500ByIdGreaterThanOrderByIdAsc(long id); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") int batchDeleteByAppId(String appId, String operator); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") int delete(String appId, String namespaceName, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java index e8c88bf68d8..dab026c945d 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/CommitRepository.java @@ -35,7 +35,7 @@ List findByAppIdAndClusterNameAndNamespaceNameAndDataChangeLastModifiedT String appId, String clusterName, String namespaceName, Date dataChangeLastModifiedTime, Pageable pageable); @Modifying - @Query("update Commit set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update Commit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") int batchDelete(String appId, String clusterName, String namespaceName, String operator); List findByAppIdAndClusterNameAndNamespaceNameAndChangeSetsLikeOrderByIdDesc(String appId, String clusterName, String namespaceName,String changeSets, Pageable page); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java index 148c0971e0d..d9d61769f4c 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java @@ -42,7 +42,7 @@ public interface ItemRepository extends PagingAndSortingRepository { Item findFirst1ByNamespaceIdOrderByLineNumDesc(Long namespaceId); @Modifying - @Query("update Item set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 where namespaceId = ?1") + @Query("update Item set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 where namespaceId = ?1") int deleteByNamespaceId(long namespaceId, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java index b1c82de7a5d..6ca111c8a97 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java @@ -33,7 +33,7 @@ public interface NamespaceRepository extends PagingAndSortingRepository findByAppIdAndNamespaceNameOrderByIdAsc(String appId, String namespaceName); diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java index 6c460434fff..1671fa194ef 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java @@ -39,7 +39,7 @@ Page findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(Stri Page findByReleaseIdAndOperationInOrderByIdDesc(long releaseId, Set operations, Pageable pageable); @Modifying - @Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") int batchDelete(String appId, String clusterName, String namespaceName, String operator); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java index e1c3bf42bd1..ce0afe3ac7f 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseRepository.java @@ -48,7 +48,7 @@ Release findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderBy List findByIdIn(Set releaseIds); @Modifying - @Query("update Release set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") + @Query("update Release set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3") int batchDelete(String appId, String clusterName, String namespaceName, String operator); // For release history conversion program, need to delete after conversion it done diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java index 19fb62c5303..57c45671964 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java @@ -28,7 +28,7 @@ @Entity @Table(name = "App") -@SQLDelete(sql = "Update App set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update App set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class App extends BaseEntity { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java index 9279f67594e..085f2e544cf 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java @@ -31,7 +31,7 @@ @Entity @Table(name = "AppNamespace") -@SQLDelete(sql = "Update AppNamespace set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update AppNamespace set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class AppNamespace extends BaseEntity { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java index 3373342c373..db32e7ca19e 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java @@ -74,8 +74,8 @@ public boolean isDeleted() { public void setDeleted(boolean deleted) { isDeleted = deleted; - // also set deletedAt value as epoch second - this.deletedAt = Instant.now().getEpochSecond(); + // also set deletedAt value as epoch millisecond + this.deletedAt = System.currentTimeMillis(); } public long getDeletedAt() { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java index 694d34955d9..2bca5e3e18a 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Consumer") -@SQLDelete(sql = "Update Consumer set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Consumer set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Consumer extends BaseEntity { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java index e88561a7fa8..2cff46a4bf4 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "ConsumerRole") -@SQLDelete(sql = "Update ConsumerRole set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ConsumerRole set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class ConsumerRole extends BaseEntity { @Column(name = "ConsumerId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java index 75071827ae6..b9ecff46104 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java @@ -32,7 +32,7 @@ */ @Entity @Table(name = "ConsumerToken") -@SQLDelete(sql = "Update ConsumerToken set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ConsumerToken set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class ConsumerToken extends BaseEntity { @Column(name = "ConsumerId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java index aa084cd48d2..7f48c3d16d5 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/repository/ConsumerRoleRepository.java @@ -43,6 +43,6 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository roleIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java index 7a172c6d36c..b5b58cd57c0 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java @@ -27,7 +27,7 @@ @Entity @Table(name = "Favorite") -@SQLDelete(sql = "Update Favorite set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Favorite set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Favorite extends BaseEntity { diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java index 74d896007b1..d074b692be6 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Permission") -@SQLDelete(sql = "Update Permission set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Permission set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Permission extends BaseEntity { @Column(name = "PermissionType", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java index 45893386391..ad33034a782 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "Role") -@SQLDelete(sql = "Update Role set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update Role set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class Role extends BaseEntity { @Column(name = "RoleName", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java index 498d4d9e574..71429d17d3c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "RolePermission") -@SQLDelete(sql = "Update RolePermission set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update RolePermission set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class RolePermission extends BaseEntity { @Column(name = "RoleId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java index d1b862f8b83..27fb0a18b8c 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java @@ -31,7 +31,7 @@ */ @Entity @Table(name = "ServerConfig") -@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update ServerConfig set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class ServerConfig extends BaseEntity { @NotBlank(message = "ServerConfig.Key cannot be blank") diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java index 2a27e872938..6709e6df076 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java @@ -30,7 +30,7 @@ */ @Entity @Table(name = "UserRole") -@SQLDelete(sql = "Update UserRole set IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP() where Id = ?") +@SQLDelete(sql = "Update UserRole set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ?") @Where(clause = "isDeleted = 0") public class UserRole extends BaseEntity { @Column(name = "UserId", nullable = false) diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java index d347e863ba9..8bc7bb0b3ec 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppNamespaceRepository.java @@ -35,10 +35,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository findByAppId(String appId); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy=?2 WHERE AppId=?1") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy=?2 WHERE AppId=?1") int batchDeleteByAppId(String appId, String operator); @Modifying - @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") + @Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2") int delete(String appId, String namespaceName, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java index 5386350be44..175395e1914 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java @@ -41,6 +41,6 @@ public interface AppRepository extends PagingAndSortingRepository { Page findByAppIdContainingOrNameContaining(String appId, String name, Pageable pageable); @Modifying - @Query("UPDATE App SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") + @Query("UPDATE App SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1") int deleteApp(String appId, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java index a6afc429eff..2198caef21b 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java @@ -36,6 +36,6 @@ public interface FavoriteRepository extends PagingAndSortingRepository findByPermissionTypeInAndTargetId(Collection permission List findPermissionIdsByAppIdAndNamespace(String appId, String namespaceName); @Modifying - @Query("UPDATE Permission SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") + @Query("UPDATE Permission SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") Integer batchDelete(List permissionIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java index 1b87b0d130a..2b1f0391b14 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java @@ -36,6 +36,6 @@ public interface RolePermissionRepository extends PagingAndSortingRepository findByRoleIdIn(Collection roleId); @Modifying - @Query("UPDATE RolePermission SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") + @Query("UPDATE RolePermission SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE PermissionId in ?1") Integer batchDeleteByPermissionIds(List permissionIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java index 03220fae09c..c7241fd5c85 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java @@ -43,6 +43,6 @@ public interface RoleRepository extends PagingAndSortingRepository { List findRoleIdsByAppIdAndNamespace(String appId, String namespaceName); @Modifying - @Query("UPDATE Role SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") + @Query("UPDATE Role SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE Id in ?1") Integer batchDelete(List roleIds, String operator); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java index 043a5f68afc..0796cf045b4 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java @@ -45,7 +45,7 @@ public interface UserRoleRepository extends PagingAndSortingRepository findByUserIdInAndRoleId(Collection userId, long roleId); @Modifying - @Query("UPDATE UserRole SET IsDeleted = 1, DeletedAt = UNIX_TIMESTAMP(), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1") + @Query("UPDATE UserRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1") Integer batchDeleteByRoleIds(List roleIds, String operator); } diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index 2db7dfe467d..ff82f9cb00a 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -41,7 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -67,7 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -92,7 +92,7 @@ CREATE TABLE `Audit` ( `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -114,7 +114,7 @@ CREATE TABLE `Cluster` ( `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -140,7 +140,7 @@ CREATE TABLE `Commit` ( `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -167,7 +167,7 @@ CREATE TABLE `GrayReleaseRule` ( `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '灰度对应的release', `BranchStatus` tinyint(2) DEFAULT '1' COMMENT '灰度分支状态: 0:删除分支,1:正在使用的规则 2:全量发布', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -236,7 +236,7 @@ CREATE TABLE `Item` ( `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `LineNum` int(10) unsigned DEFAULT '0' COMMENT '行号', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -259,7 +259,7 @@ CREATE TABLE `Namespace` ( `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name', `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -285,7 +285,7 @@ CREATE TABLE `NamespaceLock` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', `IsDeleted` bit(1) DEFAULT b'0' COMMENT '软删除', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', PRIMARY KEY (`Id`), UNIQUE KEY `IX_NamespaceId` (`NamespaceId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) @@ -309,7 +309,7 @@ CREATE TABLE `Release` ( `Configurations` longtext NOT NULL COMMENT '发布配置', `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否废弃', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -337,7 +337,7 @@ CREATE TABLE `ReleaseHistory` ( `Operation` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '发布类型,0: 普通发布,1: 回滚,2: 灰度发布,3: 灰度规则更新,4: 灰度合并回主分支发布,5: 主分支发布灰度自动发布,6: 主分支回滚灰度自动发布,7: 放弃灰度', `OperationContext` longtext NOT NULL COMMENT '发布上下文信息', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -377,7 +377,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -398,7 +398,7 @@ CREATE TABLE `AccessKey` ( `Secret` varchar(128) NOT NULL DEFAULT '' COMMENT 'Secret', `IsEnabled` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: enabled, 0: disabled', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/apolloportaldb.sql b/scripts/sql/apolloportaldb.sql index 9e356102e46..68392ffdbca 100644 --- a/scripts/sql/apolloportaldb.sql +++ b/scripts/sql/apolloportaldb.sql @@ -41,7 +41,7 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -67,7 +67,7 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -94,7 +94,7 @@ CREATE TABLE `Consumer` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -135,7 +135,7 @@ CREATE TABLE `ConsumerRole` ( `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -159,7 +159,7 @@ CREATE TABLE `ConsumerToken` ( `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -180,7 +180,7 @@ CREATE TABLE `Favorite` ( `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -201,7 +201,7 @@ CREATE TABLE `Permission` ( `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -222,7 +222,7 @@ CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -244,7 +244,7 @@ CREATE TABLE `RolePermission` ( `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -268,7 +268,7 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -290,7 +290,7 @@ CREATE TABLE `UserRole` ( `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', - `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql index d409fd119ea..887e82fe057 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql @@ -18,66 +18,66 @@ Use ApolloConfigDB; ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Audit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Cluster` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Commit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `GrayReleaseRule` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Item` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Namespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `NamespaceLock` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Release` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ReleaseHistory` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AccessKey` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql index 4044a0c16fb..01d0ef0658b 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql @@ -18,57 +18,57 @@ Use ApolloPortalDB; ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Consumer` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerRole` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerToken` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Favorite` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Permission` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Role` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `RolePermission` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `UserRole` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on seconds' AFTER `IsDeleted`, + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; From 56bae067e743a796d466c19cafda4e75d06af87f Mon Sep 17 00:00:00 2001 From: nisiyong Date: Fri, 6 Aug 2021 00:18:05 +0800 Subject: [PATCH 08/22] fix: add custom SQL function NOW() with args to adapt the @Query statements --- .../src/main/resources/application.yml | 4 ++++ .../src/main/resources/application.yml | 4 ++++ ...SqlFunctionsMetadataBuilderContributor.java | 18 ++++++++++++++++++ .../src/main/resources/application.yml | 4 ++++ .../src/main/resources/application.yml | 1 + 5 files changed, 31 insertions(+) create mode 100644 apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java diff --git a/apollo-adminservice/src/main/resources/application.yml b/apollo-adminservice/src/main/resources/application.yml index 44568f65d8e..e7e70ad488f 100644 --- a/apollo-adminservice/src/main/resources/application.yml +++ b/apollo-adminservice/src/main/resources/application.yml @@ -23,6 +23,10 @@ spring: enabled: false zookeeper: enabled: false + jpa: + properties: + hibernate: + metadata_builder_contributor: com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor ctrip: appid: 100003172 diff --git a/apollo-assembly/src/main/resources/application.yml b/apollo-assembly/src/main/resources/application.yml index c02d28e3820..e87c8a5d881 100644 --- a/apollo-assembly/src/main/resources/application.yml +++ b/apollo-assembly/src/main/resources/application.yml @@ -23,6 +23,10 @@ spring: enabled: false session: store-type: none + jpa: + properties: + hibernate: + metadata_builder_contributor: com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor logging: file: diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java new file mode 100644 index 00000000000..a22ae2a15c2 --- /dev/null +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java @@ -0,0 +1,18 @@ +package com.ctrip.framework.apollo.common.jpa; + +import org.hibernate.boot.MetadataBuilder; +import org.hibernate.boot.spi.MetadataBuilderContributor; +import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.type.StandardBasicTypes; + +/** + * @author nisiyong + */ +public class SqlFunctionsMetadataBuilderContributor implements MetadataBuilderContributor { + + @Override + public void contribute(MetadataBuilder metadataBuilder) { + metadataBuilder.applySqlFunction("NOW", + new StandardSQLFunction("NOW", StandardBasicTypes.INTEGER)); + } +} diff --git a/apollo-configservice/src/main/resources/application.yml b/apollo-configservice/src/main/resources/application.yml index 469edbaf585..0103e65ca94 100644 --- a/apollo-configservice/src/main/resources/application.yml +++ b/apollo-configservice/src/main/resources/application.yml @@ -23,6 +23,10 @@ spring: enabled: false zookeeper: enabled: false + jpa: + properties: + hibernate: + metadata_builder_contributor: com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor ctrip: appid: 100003171 diff --git a/apollo-portal/src/main/resources/application.yml b/apollo-portal/src/main/resources/application.yml index a47d64db40a..d8c88cd9828 100644 --- a/apollo-portal/src/main/resources/application.yml +++ b/apollo-portal/src/main/resources/application.yml @@ -21,6 +21,7 @@ spring: jpa: properties: hibernate: + metadata_builder_contributor: com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor query: plan_cache_max_size: 192 # limit query plan cache max size session: From 4d027a46eb6c141ae9bbdb32776366f72d3789b3 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Mon, 9 Aug 2021 22:34:27 +0800 Subject: [PATCH 09/22] test: update application.properties --- apollo-adminservice/src/test/resources/application.properties | 1 + apollo-assembly/src/test/resources/application.properties | 1 + apollo-biz/src/test/resources/application.properties | 1 + apollo-configservice/src/test/resources/application.properties | 3 ++- apollo-portal/src/test/resources/application.properties | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apollo-adminservice/src/test/resources/application.properties b/apollo-adminservice/src/test/resources/application.properties index 3731f994d93..1fc7fe30076 100644 --- a/apollo-adminservice/src/test/resources/application.properties +++ b/apollo-adminservice/src/test/resources/application.properties @@ -16,6 +16,7 @@ spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=false +spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true spring.main.allow-bean-definition-overriding=true diff --git a/apollo-assembly/src/test/resources/application.properties b/apollo-assembly/src/test/resources/application.properties index 9dd884cfd96..fd5ed8d5558 100644 --- a/apollo-assembly/src/test/resources/application.properties +++ b/apollo-assembly/src/test/resources/application.properties @@ -16,6 +16,7 @@ spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=false +spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true apollo.portal.env= local diff --git a/apollo-biz/src/test/resources/application.properties b/apollo-biz/src/test/resources/application.properties index e9f865d3e1b..9f29c30a432 100644 --- a/apollo-biz/src/test/resources/application.properties +++ b/apollo-biz/src/test/resources/application.properties @@ -16,6 +16,7 @@ spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=false +spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true spring.cloud.consul.enabled=false diff --git a/apollo-configservice/src/test/resources/application.properties b/apollo-configservice/src/test/resources/application.properties index cc574d7b92f..6d7364fce80 100644 --- a/apollo-configservice/src/test/resources/application.properties +++ b/apollo-configservice/src/test/resources/application.properties @@ -15,9 +15,10 @@ # spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.properties.hibernate.show_sql=false +spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true -spring.jpa.properties.hibernate.show_sql=false spring.cloud.consul.enabled=false spring.cloud.zookeeper.enabled=false spring.main.allow-bean-definition-overriding=true diff --git a/apollo-portal/src/test/resources/application.properties b/apollo-portal/src/test/resources/application.properties index eef4606c8bb..e502376bfdc 100644 --- a/apollo-portal/src/test/resources/application.properties +++ b/apollo-portal/src/test/resources/application.properties @@ -17,6 +17,7 @@ spring.session.store-type=none spring.datasource.url = jdbc:h2:mem:~/apolloportaldb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=false +spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true spring.main.allow-bean-definition-overriding=true From 708f8a505a81ca2aa0d2995b837321b2c6a32e71 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Mon, 9 Aug 2021 22:57:38 +0800 Subject: [PATCH 10/22] fix: deletedAt NPE --- .../com/ctrip/framework/apollo/common/entity/BaseEntity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java index db32e7ca19e..cff4ac0fae8 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java @@ -82,8 +82,8 @@ public long getDeletedAt() { return deletedAt; } - public void setDeletedAt(long deletedAt) { - this.deletedAt = deletedAt; + public void setDeletedAt(Long deletedAt) { + this.deletedAt = deletedAt == null ? 0 : deletedAt; } public String getDataChangeCreatedBy() { From 2b007e0b8221207b863d1e97f2f0cb85c7c12e56 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Tue, 10 Aug 2021 00:05:26 +0800 Subject: [PATCH 11/22] test: create alias for H2 function --- apollo-adminservice/src/test/resources/import.sql | 1 + apollo-biz/src/test/resources/import.sql | 1 + .../framework/apollo/common/entity/BaseEntity.java | 6 +++--- .../ctrip/framework/apollo/common/jpa/H2Function.java | 11 +++++++++++ apollo-configservice/src/main/resources/import.sql | 1 + apollo-portal/src/test/resources/import.sql | 1 + 6 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 apollo-adminservice/src/test/resources/import.sql create mode 100644 apollo-biz/src/test/resources/import.sql create mode 100644 apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java create mode 100644 apollo-configservice/src/main/resources/import.sql create mode 100644 apollo-portal/src/test/resources/import.sql diff --git a/apollo-adminservice/src/test/resources/import.sql b/apollo-adminservice/src/test/resources/import.sql new file mode 100644 index 00000000000..6b2e51e5c9e --- /dev/null +++ b/apollo-adminservice/src/test/resources/import.sql @@ -0,0 +1 @@ +CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file diff --git a/apollo-biz/src/test/resources/import.sql b/apollo-biz/src/test/resources/import.sql new file mode 100644 index 00000000000..6b2e51e5c9e --- /dev/null +++ b/apollo-biz/src/test/resources/import.sql @@ -0,0 +1 @@ +CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java index cff4ac0fae8..aba375906c4 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/BaseEntity.java @@ -45,7 +45,7 @@ public abstract class BaseEntity { @Column(name = "IsDeleted", columnDefinition = "Bit default '0'") protected boolean isDeleted = false; - @Column(name = "DeletedAt") + @Column(name = "DeletedAt", columnDefinition = "Bigint default '0'") protected long deletedAt; @Column(name = "DataChange_CreatedBy", nullable = false) @@ -82,8 +82,8 @@ public long getDeletedAt() { return deletedAt; } - public void setDeletedAt(Long deletedAt) { - this.deletedAt = deletedAt == null ? 0 : deletedAt; + public void setDeletedAt(long deletedAt) { + this.deletedAt = deletedAt; } public String getDataChangeCreatedBy() { diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java new file mode 100644 index 00000000000..5b5bde39f8e --- /dev/null +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java @@ -0,0 +1,11 @@ +package com.ctrip.framework.apollo.common.jpa; + +/** + * @author nisiyong + */ +public class H2Function { + + public static long unixTimestamp(java.sql.Timestamp timestamp) { + return timestamp.getTime() / 1000L; + } +} diff --git a/apollo-configservice/src/main/resources/import.sql b/apollo-configservice/src/main/resources/import.sql new file mode 100644 index 00000000000..6b2e51e5c9e --- /dev/null +++ b/apollo-configservice/src/main/resources/import.sql @@ -0,0 +1 @@ +CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file diff --git a/apollo-portal/src/test/resources/import.sql b/apollo-portal/src/test/resources/import.sql new file mode 100644 index 00000000000..6b2e51e5c9e --- /dev/null +++ b/apollo-portal/src/test/resources/import.sql @@ -0,0 +1 @@ +CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file From f230cc1a7db23f4e7e1ca8ba2928606e0b5cb9bd Mon Sep 17 00:00:00 2001 From: nisiyong Date: Tue, 10 Aug 2021 00:18:20 +0800 Subject: [PATCH 12/22] fix: license check --- .../src/test/resources/import.sql | 15 +++++++++++++++ apollo-biz/src/test/resources/import.sql | 15 +++++++++++++++ .../framework/apollo/common/jpa/H2Function.java | 16 ++++++++++++++++ .../SqlFunctionsMetadataBuilderContributor.java | 16 ++++++++++++++++ .../src/main/resources/import.sql | 15 +++++++++++++++ apollo-portal/src/test/resources/import.sql | 15 +++++++++++++++ 6 files changed, 92 insertions(+) diff --git a/apollo-adminservice/src/test/resources/import.sql b/apollo-adminservice/src/test/resources/import.sql index 6b2e51e5c9e..2fe5eb1d969 100644 --- a/apollo-adminservice/src/test/resources/import.sql +++ b/apollo-adminservice/src/test/resources/import.sql @@ -1 +1,16 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file diff --git a/apollo-biz/src/test/resources/import.sql b/apollo-biz/src/test/resources/import.sql index 6b2e51e5c9e..2fe5eb1d969 100644 --- a/apollo-biz/src/test/resources/import.sql +++ b/apollo-biz/src/test/resources/import.sql @@ -1 +1,16 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java index 5b5bde39f8e..81199f6350a 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package com.ctrip.framework.apollo.common.jpa; /** diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java index a22ae2a15c2..4bfb4fc3764 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 Apollo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package com.ctrip.framework.apollo.common.jpa; import org.hibernate.boot.MetadataBuilder; diff --git a/apollo-configservice/src/main/resources/import.sql b/apollo-configservice/src/main/resources/import.sql index 6b2e51e5c9e..2fe5eb1d969 100644 --- a/apollo-configservice/src/main/resources/import.sql +++ b/apollo-configservice/src/main/resources/import.sql @@ -1 +1,16 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file diff --git a/apollo-portal/src/test/resources/import.sql b/apollo-portal/src/test/resources/import.sql index 6b2e51e5c9e..2fe5eb1d969 100644 --- a/apollo-portal/src/test/resources/import.sql +++ b/apollo-portal/src/test/resources/import.sql @@ -1 +1,16 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- CREATE ALIAS IF NOT EXISTS UNIX_TIMESTAMP FOR "com.ctrip.framework.apollo.common.jpa.H2Function.unixTimestamp"; \ No newline at end of file From e56d273db67ba0aeed73a35ecb7f64a9bedd5232 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Wed, 11 Aug 2021 10:25:50 +0800 Subject: [PATCH 13/22] fix: move import.sql to the test package --- apollo-configservice/src/{main => test}/resources/import.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apollo-configservice/src/{main => test}/resources/import.sql (100%) diff --git a/apollo-configservice/src/main/resources/import.sql b/apollo-configservice/src/test/resources/import.sql similarity index 100% rename from apollo-configservice/src/main/resources/import.sql rename to apollo-configservice/src/test/resources/import.sql From 4871fbc5435d95acfc8eb92d872f004b8ad5a887 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 4 Sep 2021 10:56:04 +0800 Subject: [PATCH 14/22] fix: move delta sql from v180-v190 to v1_9_0-v1_10_0 --- .../v180-v190/apolloconfigdb-v180-v190.sql | 13 ----- .../v180-v190/apolloportaldb-v180-v190.sql | 12 ---- .../apolloconfigdb-v1_9_0-v1_10_0-after.sql} | 2 +- .../apolloconfigdb-v1_9_0-v1_10_0.sql | 57 +++++++++++++++++++ .../apolloportaldb-v1_9_0-v1_10_0-after.sql} | 2 +- .../apolloportaldb-v1_9_0-v1_10_0.sql | 51 +++++++++++++++++ 6 files changed, 110 insertions(+), 27 deletions(-) rename scripts/sql/delta/{v180-v190/apolloconfigdb-v180-v190-after.sql => v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql} (96%) create mode 100644 scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql rename scripts/sql/delta/{v180-v190/apolloportaldb-v180-v190-after.sql => v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql} (96%) create mode 100644 scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql index 887e82fe057..34425039e72 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql @@ -18,66 +18,53 @@ Use ApolloConfigDB; ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Audit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Cluster` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Commit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `GrayReleaseRule` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Item` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Namespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `NamespaceLock` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Release` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ReleaseHistory` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AccessKey` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql index 01d0ef0658b..e50688a545d 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql +++ b/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql @@ -18,64 +18,52 @@ Use ApolloPortalDB; ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Consumer` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerRole` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ConsumerToken` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Favorite` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Permission` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Role` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `RolePermission` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `UserRole` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, MODIFY COLUMN `DataChange_CreatedBy` VARCHAR(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', MODIFY COLUMN `DataChange_LastModifiedBy` VARCHAR(64) DEFAULT '' COMMENT '最后修改人邮箱前缀'; ALTER TABLE `Users` MODIFY COLUMN `Username` varchar(64) NOT NULL DEFAULT 'default' COMMENT '用户登录账户', ADD COLUMN `UserDisplayName` varchar(512) NOT NULL DEFAULT 'default' COMMENT '用户名称' AFTER `Password`; - UPDATE `Users` SET `UserDisplayName`=`Username` WHERE `UserDisplayName` = 'default'; ALTER TABLE `Users` diff --git a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql similarity index 96% rename from scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql rename to scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql index 2e6450f79fa..3993b0746fa 100644 --- a/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190-after.sql +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql @@ -13,7 +13,7 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- -# delta schema to upgrade apollo config db from v1.8.0 to v1.9.0 +# delta schema to upgrade apollo config db from v1.9.0 to v1.10.0 Use ApolloConfigDB; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql new file mode 100644 index 00000000000..deff12b6718 --- /dev/null +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql @@ -0,0 +1,57 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo config db from v1.9.0 to v1.10.0 + +Use ApolloConfigDB; + +ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Audit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Cluster` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Commit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `GrayReleaseRule` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Item` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Namespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `NamespaceLock` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Release` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ReleaseHistory` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AccessKey` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; diff --git a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql similarity index 96% rename from scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql rename to scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql index 42c9b44347b..ea41a850c73 100644 --- a/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190-after.sql +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql @@ -13,7 +13,7 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- -# delta schema to upgrade apollo portal db from v1.8.0 to v1.9.0 +# delta schema to upgrade apollo portal db from v1.9.0 to v1.10.0 Use ApolloPortalDB; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql new file mode 100644 index 00000000000..3358424cb56 --- /dev/null +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql @@ -0,0 +1,51 @@ +-- +-- Copyright 2021 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo portal db from v1.9.0 to v1.10.0 + +Use ApolloPortalDB; + +ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Consumer` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ConsumerRole` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ConsumerToken` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Favorite` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Permission` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Role` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `RolePermission` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `UserRole` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; \ No newline at end of file From 64a1df5c787f3590bb7ba455d2333060f6cc3396 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 4 Sep 2021 13:52:41 +0800 Subject: [PATCH 15/22] feat: add UNIQUE CONSTRAINT INDEX for each table --- scripts/sql/apolloconfigdb.sql | 24 ++++----- scripts/sql/apolloportaldb.sql | 29 +++++------ .../apolloconfigdb-v1_9_0-v1_10_0-after.sql | 49 ++++++++++++++++++- .../apolloportaldb-v1_9_0-v1_10_0-after.sql | 48 +++++++++++++++++- 4 files changed, 121 insertions(+), 29 deletions(-) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index ff82f9cb00a..ababb316fb3 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -47,7 +47,7 @@ CREATE TABLE `App` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_Name` (`Name`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表'; @@ -73,7 +73,7 @@ CREATE TABLE `AppNamespace` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_AppId` (`AppId`), + UNIQUE KEY `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), KEY `Name_AppId` (`Name`,`AppId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义'; @@ -120,7 +120,7 @@ CREATE TABLE `Cluster` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_AppId_Name` (`AppId`,`Name`), + UNIQUE KEY `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), KEY `IX_ParentClusterId` (`ParentClusterId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集群'; @@ -173,8 +173,8 @@ CREATE TABLE `GrayReleaseRule` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_Namespace` (`AppId`,`ClusterName`,`NamespaceName`) + UNIQUE KEY `UK_AppId_ClusterName_NamespaceName_BranchName_DeletedAt` (`AppId`,`ClusterName`,`NamespaceName`,`BranchName`,`DeletedAt`), + KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='灰度规则表'; @@ -242,7 +242,7 @@ CREATE TABLE `Item` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_GroupId` (`NamespaceId`), + UNIQUE KEY `UK_NamespaceId_Key_DeletedAt` (`NamespaceId`,`Key`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置项目'; @@ -265,7 +265,7 @@ CREATE TABLE `Namespace` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId_ClusterName_NamespaceName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)), + UNIQUE KEY `UK_AppId_ClusterName_NamespaceName_DeletedAt` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191),`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_NamespaceName` (`NamespaceName`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='命名空间'; @@ -287,7 +287,7 @@ CREATE TABLE `NamespaceLock` ( `IsDeleted` bit(1) DEFAULT b'0' COMMENT '软删除', `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', PRIMARY KEY (`Id`), - UNIQUE KEY `IX_NamespaceId` (`NamespaceId`), + UNIQUE KEY `UK_NamespaceId_DeletedAt` (`NamespaceId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='namespace的编辑锁'; @@ -315,9 +315,9 @@ CREATE TABLE `Release` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_ReleaseKey_DeletedAt` (`ReleaseKey`,`DeletedAt`), KEY `AppId_ClusterName_GroupName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)), - KEY `DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_ReleaseKey` (`ReleaseKey`) + KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='发布'; @@ -383,7 +383,7 @@ CREATE TABLE `ServerConfig` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_Key` (`Key`), + UNIQUE KEY `UK_Key_DeletedAt` (`Key`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; @@ -404,7 +404,7 @@ CREATE TABLE `AccessKey` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_Secret_DeletedAt` (`AppId`,`Secret`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问密钥'; diff --git a/scripts/sql/apolloportaldb.sql b/scripts/sql/apolloportaldb.sql index 68392ffdbca..fb333c57da7 100644 --- a/scripts/sql/apolloportaldb.sql +++ b/scripts/sql/apolloportaldb.sql @@ -47,7 +47,7 @@ CREATE TABLE `App` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_Name` (`Name`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表'; @@ -73,7 +73,7 @@ CREATE TABLE `AppNamespace` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_AppId` (`AppId`), + UNIQUE KEY `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), KEY `Name_AppId` (`Name`,`AppId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义'; @@ -100,7 +100,7 @@ CREATE TABLE `Consumer` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开放API消费者'; @@ -141,9 +141,9 @@ CREATE TABLE `ConsumerRole` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_ConsumerId_RoleId_DeletedAt` (`ConsumerId`,`RoleId`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_RoleId` (`RoleId`), - KEY `IX_ConsumerId_RoleId` (`ConsumerId`,`RoleId`) + KEY `IX_RoleId` (`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer和role的绑定表'; @@ -165,7 +165,7 @@ CREATE TABLE `ConsumerToken` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - UNIQUE KEY `IX_Token` (`Token`), + UNIQUE KEY `UK_Token_DeletedAt` (`Token`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer token表'; @@ -186,8 +186,8 @@ CREATE TABLE `Favorite` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_UserId_AppId_DeletedAt` (`UserId`,`AppId`,`DeletedAt`), KEY `AppId` (`AppId`(191)), - KEY `IX_UserId` (`UserId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COMMENT='应用收藏表'; @@ -207,7 +207,7 @@ CREATE TABLE `Permission` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_TargetId_PermissionType` (`TargetId`(191),`PermissionType`), + UNIQUE KEY `UK_TargetId_PermissionType_DeletedAt` (`TargetId`,`PermissionType`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='permission表'; @@ -228,7 +228,7 @@ CREATE TABLE `Role` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_RoleName` (`RoleName`(191)), + UNIQUE KEY `UK_RoleName_DeletedAt` (`RoleName`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表'; @@ -250,8 +250,8 @@ CREATE TABLE `RolePermission` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_RoleId_PermissionId_DeletedAt` (`RoleId`,`PermissionId`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_RoleId` (`RoleId`), KEY `IX_PermissionId` (`PermissionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和权限的绑定表'; @@ -274,7 +274,7 @@ CREATE TABLE `ServerConfig` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_Key` (`Key`), + UNIQUE KEY `UK_Key_DeletedAt` (`Key`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; @@ -296,9 +296,9 @@ CREATE TABLE `UserRole` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_UserId_RoleId_DeletedAt` (`UserId`,`RoleId`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_RoleId` (`RoleId`), - KEY `IX_UserId_RoleId` (`UserId`,`RoleId`) + KEY `IX_RoleId` (`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和role的绑定表'; # Dump of table Users @@ -313,7 +313,8 @@ CREATE TABLE `Users` ( `UserDisplayName` varchar(512) NOT NULL DEFAULT 'default' COMMENT '用户名称', `Email` varchar(64) NOT NULL DEFAULT 'default' COMMENT '邮箱地址', `Enabled` tinyint(4) DEFAULT NULL COMMENT '是否有效', - PRIMARY KEY (`Id`) + PRIMARY KEY (`Id`), + UNIQUE KEY `UK_Username` (`Username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表'; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql index 3993b0746fa..85fc5bd38d7 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql @@ -17,6 +17,7 @@ Use ApolloConfigDB; +UPDATE `AccessKey` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; UPDATE `App` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; UPDATE `AppNamespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; UPDATE `Audit` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; @@ -29,6 +30,50 @@ UPDATE `NamespaceLock` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedA UPDATE `Release` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; UPDATE `ReleaseHistory` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; UPDATE `ServerConfig` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `AccessKey` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; --- TODO: add UNIQUE CONSTRAINT INDEX for each table \ No newline at end of file +-- add UNIQUE CONSTRAINT INDEX for each table +ALTER TABLE `AccessKey` + ADD UNIQUE INDEX `UK_AppId_Secret_DeletedAt` (`AppId`,`Secret`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `App` + ADD UNIQUE INDEX `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `AppNamespace` + ADD UNIQUE INDEX `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), + DROP INDEX `IX_AppId`; + +-- Ignore TABLE `Audit` + +ALTER TABLE `Cluster` + ADD UNIQUE INDEX `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), + DROP INDEX `IX_AppId_Name`; + +-- Ignore TABLE `Commit` + +ALTER TABLE `GrayReleaseRule` + ADD UNIQUE INDEX `UK_AppId_ClusterName_NamespaceName_BranchName_DeletedAt` (`AppId`,`ClusterName`,`NamespaceName`,`BranchName`,`DeletedAt`), + DROP INDEX `IX_Namespace`; + +ALTER TABLE `Item` + ADD UNIQUE INDEX `UK_NamespaceId_Key_DeletedAt` (`NamespaceId`,`Key`,`DeletedAt`), + DROP INDEX `IX_GroupId`; + +ALTER TABLE `Namespace` + ADD UNIQUE INDEX `UK_AppId_ClusterName_NamespaceName_DeletedAt` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191),`DeletedAt`), + DROP INDEX `AppId_ClusterName_NamespaceName`; + +ALTER TABLE `NamespaceLock` + ADD UNIQUE INDEX `UK_NamespaceId_DeletedAt` (`NamespaceId`,`DeletedAt`), + DROP INDEX `IX_NamespaceId`; + +ALTER TABLE `Release` + ADD UNIQUE INDEX `UK_ReleaseKey_DeletedAt` (`ReleaseKey`,`DeletedAt`), + DROP INDEX `IX_ReleaseKey`; + +-- Ignore TABLE `ReleaseHistory` + +ALTER TABLE `ServerConfig` + ADD UNIQUE INDEX `UK_Key_DeletedAt` (`Key`,`DeletedAt`), + DROP INDEX `IX_Key`; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql index ea41a850c73..68a4d014ac7 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql @@ -29,4 +29,50 @@ UPDATE `RolePermission` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `Deleted UPDATE `ServerConfig` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; UPDATE `UserRole` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; --- TODO: add UNIQUE CONSTRAINT INDEX for each table \ No newline at end of file +-- add UNIQUE CONSTRAINT INDEX for each table +ALTER TABLE `App` + ADD UNIQUE INDEX `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `AppNamespace` + ADD UNIQUE INDEX `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), + DROP INDEX `IX_AppId`; + +ALTER TABLE `Consumer` + ADD UNIQUE INDEX `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `ConsumerRole` + ADD UNIQUE INDEX `UK_ConsumerId_RoleId_DeletedAt` (`ConsumerId`,`RoleId`,`DeletedAt`), + DROP INDEX `IX_ConsumerId_RoleId`; + +ALTER TABLE `ConsumerToken` + ADD UNIQUE INDEX `UK_Token_DeletedAt` (`Token`,`DeletedAt`), + DROP INDEX `IX_Token`; + +ALTER TABLE `Favorite` + ADD UNIQUE INDEX `UK_UserId_AppId_DeletedAt` (`UserId`,`AppId`,`DeletedAt`), + DROP INDEX `IX_UserId`; + +ALTER TABLE `Permission` + ADD UNIQUE INDEX `UK_TargetId_PermissionType_DeletedAt` (`TargetId`,`PermissionType`,`DeletedAt`), + DROP INDEX `IX_TargetId_PermissionType`; + +ALTER TABLE `Role` + ADD UNIQUE INDEX `UK_RoleName_DeletedAt` (`RoleName`,`DeletedAt`), + DROP INDEX `IX_RoleName`; + +ALTER TABLE `RolePermission` + ADD UNIQUE INDEX `UK_RoleId_PermissionId_DeletedAt` (`RoleId`,`PermissionId`,`DeletedAt`), + DROP INDEX `IX_RoleId`; + +ALTER TABLE `ServerConfig` + ADD UNIQUE INDEX `UK_Key_DeletedAt` (`Key`,`DeletedAt`), + DROP INDEX `IX_Key`; + +ALTER TABLE `UserRole` + ADD UNIQUE INDEX `UK_UserId_RoleId_DeletedAt` (`UserId`,`RoleId`,`DeletedAt`), + DROP INDEX `IX_UserId_RoleId`; + +ALTER TABLE `Users` + ADD UNIQUE INDEX `UK_Username` (`Username`); From d7ec1f9b25b93c4b4bb5776e96570fa8a69a4c45 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 5 Sep 2021 00:21:49 +0800 Subject: [PATCH 16/22] docs: update the CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 2d2019ea529..04866490b1d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,6 +45,6 @@ Apollo 2.0.0 * [optimize import/export config](https://github.com/apolloconfig/apollo/pull/4231) * [Configure publish and rollback modal boxes to add scrollbars](https://github.com/apolloconfig/apollo/pull/4251) * [fix import config bug](https://github.com/apolloconfig/apollo/pull/4262) - +* [Refactor the soft delete design](https://github.com/apolloconfig/apollo/pull/3866) ------------------ All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/8?closed=1) From 3e62f1568d540d3c11b8b52df1aae68808b777d9 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Tue, 21 Sep 2021 10:24:01 +0800 Subject: [PATCH 17/22] fix: update Item unique key to support multi empty keys --- scripts/sql/apolloconfigdb.sql | 2 +- .../v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index ababb316fb3..bce0c97e815 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -242,7 +242,7 @@ CREATE TABLE `Item` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - UNIQUE KEY `UK_NamespaceId_Key_DeletedAt` (`NamespaceId`,`Key`,`DeletedAt`), + UNIQUE KEY `UK_NamespaceId_LineNum_Key_DeletedAt` (`NamespaceId`,`Key`,`LineNum`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置项目'; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql index 85fc5bd38d7..11ffcb1d544 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql @@ -57,7 +57,7 @@ ALTER TABLE `GrayReleaseRule` DROP INDEX `IX_Namespace`; ALTER TABLE `Item` - ADD UNIQUE INDEX `UK_NamespaceId_Key_DeletedAt` (`NamespaceId`,`Key`,`DeletedAt`), + ADD UNIQUE INDEX `UK_NamespaceId_LineNum_Key_DeletedAt` (`NamespaceId`,`Key`,`LineNum`,`DeletedAt`), DROP INDEX `IX_GroupId`; ALTER TABLE `Namespace` From c112121dee1fc855e4dccf4d1de7d38682bba884 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Tue, 21 Sep 2021 14:20:51 +0800 Subject: [PATCH 18/22] fix: add Cluster Column in unique keys on ApolloConfigDB.ServerConfig --- scripts/sql/apolloconfigdb.sql | 2 +- .../v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index bce0c97e815..7849a43257e 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -383,7 +383,7 @@ CREATE TABLE `ServerConfig` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - UNIQUE KEY `UK_Key_DeletedAt` (`Key`,`DeletedAt`), + UNIQUE KEY `UK_Key_Cluster_DeletedAt` (`Key`,`Cluster`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql index 11ffcb1d544..6c0d997ac2e 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql +++ b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql @@ -75,5 +75,5 @@ ALTER TABLE `Release` -- Ignore TABLE `ReleaseHistory` ALTER TABLE `ServerConfig` - ADD UNIQUE INDEX `UK_Key_DeletedAt` (`Key`,`DeletedAt`), + ADD UNIQUE INDEX `UK_Key_Cluster_DeletedAt` (`Key`,`Cluster`,`DeletedAt`), DROP INDEX `IX_Key`; From 2a5b71856b4a5f274fcc27b423dee9c50e3ada93 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Thu, 10 Mar 2022 22:16:38 +0800 Subject: [PATCH 19/22] fix: move sql to v190-v200 and polish DML --- .../apolloconfigdb-v190-v200-after.sql} | 29 +++++----- .../v190-v200/apolloconfigdb-v190-v200.sql | 42 +++++++++++++- .../apolloportaldb-v190-v200-after.sql} | 25 ++++---- .../apolloportaldb-v190-v200.sql} | 2 +- .../apolloconfigdb-v1_9_0-v1_10_0.sql | 57 ------------------- 5 files changed, 69 insertions(+), 86 deletions(-) rename scripts/sql/delta/{v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql => v190-v200/apolloconfigdb-v190-v200-after.sql} (54%) rename scripts/sql/delta/{v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql => v190-v200/apolloportaldb-v190-v200-after.sql} (58%) rename scripts/sql/delta/{v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql => v190-v200/apolloportaldb-v190-v200.sql} (97%) delete mode 100644 scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql similarity index 54% rename from scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql rename to scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql index 6c0d997ac2e..1b971368284 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0-after.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql @@ -13,23 +13,24 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- -# delta schema to upgrade apollo config db from v1.9.0 to v1.10.0 +# delta schema to upgrade apollo config db from v1.9.0 to v2.0.0 Use ApolloConfigDB; -UPDATE `AccessKey` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `App` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `AppNamespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Audit` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Cluster` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Commit` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `GrayReleaseRule` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Item` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Namespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `NamespaceLock` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Release` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `ReleaseHistory` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `ServerConfig` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +-- the follow DML won't change the `DataChange_LastTime` field +UPDATE `AccessKey` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `App` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AppNamespace` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Audit` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Cluster` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Commit` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `GrayReleaseRule` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Item` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Namespace` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `NamespaceLock` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Release` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ReleaseHistory` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ServerConfig` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -- add UNIQUE CONSTRAINT INDEX for each table ALTER TABLE `AccessKey` diff --git a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql index 09ec2925047..afcee5d6fd0 100644 --- a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql @@ -1,5 +1,5 @@ -- --- Copyright 2022 Apollo Authors +-- Copyright 2021 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -17,4 +17,42 @@ Use ApolloConfigDB; -ALTER TABLE Item ADD INDEX IX_key (`Key`); +ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Audit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Cluster` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Commit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `GrayReleaseRule` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Item` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD INDEX IX_key (`Key`); + +ALTER TABLE `Namespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `NamespaceLock` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Release` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ReleaseHistory` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AccessKey` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql similarity index 58% rename from scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql rename to scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql index 68a4d014ac7..efdac97c652 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0-after.sql +++ b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql @@ -13,21 +13,22 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- -# delta schema to upgrade apollo portal db from v1.9.0 to v1.10.0 +# delta schema to upgrade apollo portal db from v1.9.0 to v2.0.0 Use ApolloPortalDB; -UPDATE `App` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `AppNamespace` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Consumer` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `ConsumerRole` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `ConsumerToken` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Favorite` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Permission` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `Role` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `RolePermission` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `ServerConfig` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -UPDATE `UserRole` SET `DeletedAt` = -Id WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +-- the follow DML won't change the `DataChange_LastTime` field +UPDATE `App` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AppNamespace` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Consumer` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ConsumerRole` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ConsumerToken` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Favorite` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Permission` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Role` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `RolePermission` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ServerConfig` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `UserRole` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; -- add UNIQUE CONSTRAINT INDEX for each table ALTER TABLE `App` diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql similarity index 97% rename from scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql rename to scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql index 3358424cb56..0e6243c69f3 100644 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloportaldb-v1_9_0-v1_10_0.sql +++ b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql @@ -13,7 +13,7 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- -# delta schema to upgrade apollo portal db from v1.9.0 to v1.10.0 +# delta schema to upgrade apollo portal db from v1.9.0 to v2.0.0 Use ApolloPortalDB; diff --git a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql b/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql deleted file mode 100644 index deff12b6718..00000000000 --- a/scripts/sql/delta/v1_9_0-v1_10_0/apolloconfigdb-v1_9_0-v1_10_0.sql +++ /dev/null @@ -1,57 +0,0 @@ --- --- Copyright 2021 Apollo Authors --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- -# delta schema to upgrade apollo config db from v1.9.0 to v1.10.0 - -Use ApolloConfigDB; - -ALTER TABLE `App` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `AppNamespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `Audit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `Cluster` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `Commit` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `GrayReleaseRule` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `Item` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `Namespace` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `NamespaceLock` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `Release` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `ReleaseHistory` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `ServerConfig` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; - -ALTER TABLE `AccessKey` - ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; From 82cbdb5a4ab666f8b2731667776e555841614647 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 12 Mar 2022 17:36:44 +0800 Subject: [PATCH 20/22] feat: remove unique index DDL on `GrayReleaseRule` and `Item` --- scripts/sql/apolloconfigdb.sql | 6 +++--- .../delta/v190-v200/apolloconfigdb-v190-v200-after.sql | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index 7849a43257e..60c497f60e7 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -173,8 +173,8 @@ CREATE TABLE `GrayReleaseRule` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - UNIQUE KEY `UK_AppId_ClusterName_NamespaceName_BranchName_DeletedAt` (`AppId`,`ClusterName`,`NamespaceName`,`BranchName`,`DeletedAt`), - KEY `DataChange_LastTime` (`DataChange_LastTime`) + KEY `DataChange_LastTime` (`DataChange_LastTime`), + KEY `IX_Namespace` (`AppId`,`ClusterName`,`NamespaceName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='灰度规则表'; @@ -242,7 +242,7 @@ CREATE TABLE `Item` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - UNIQUE KEY `UK_NamespaceId_LineNum_Key_DeletedAt` (`NamespaceId`,`Key`,`LineNum`,`DeletedAt`), + KEY `IX_GroupId` (`NamespaceId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置项目'; diff --git a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql index 1b971368284..286847ce1aa 100644 --- a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql @@ -53,13 +53,9 @@ ALTER TABLE `Cluster` -- Ignore TABLE `Commit` -ALTER TABLE `GrayReleaseRule` - ADD UNIQUE INDEX `UK_AppId_ClusterName_NamespaceName_BranchName_DeletedAt` (`AppId`,`ClusterName`,`NamespaceName`,`BranchName`,`DeletedAt`), - DROP INDEX `IX_Namespace`; +-- Ignore TABLE `GrayReleaseRule`, add unique index in future -ALTER TABLE `Item` - ADD UNIQUE INDEX `UK_NamespaceId_LineNum_Key_DeletedAt` (`NamespaceId`,`Key`,`LineNum`,`DeletedAt`), - DROP INDEX `IX_GroupId`; +-- Ignore TABLE `Item`, add unique index in future ALTER TABLE `Namespace` ADD UNIQUE INDEX `UK_AppId_ClusterName_NamespaceName_DeletedAt` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191),`DeletedAt`), From 269029709c7eb769ba30f3301172e53a60e53a6f Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 12 Mar 2022 18:05:56 +0800 Subject: [PATCH 21/22] feat: update sql scripts for docker-quick-stark and flyway --- .../docker-quick-start/sql/apolloconfigdb.sql | 31 +++++--- .../docker-quick-start/sql/apolloportaldb.sql | 40 ++++++---- .../configdb/V2.0.0__add-column-deletedat.sql | 58 ++++++++++++++ .../configdb/V2.0.1__add-unique-key.sql | 76 ++++++++++++++++++ .../portaldb/V2.0.0__add-column-deletedat.sql | 51 ++++++++++++ .../portaldb/V2.0.1__add-unique-key.sql | 79 +++++++++++++++++++ 6 files changed, 312 insertions(+), 23 deletions(-) create mode 100644 scripts/flyway/configdb/V2.0.0__add-column-deletedat.sql create mode 100644 scripts/flyway/configdb/V2.0.1__add-unique-key.sql create mode 100644 scripts/flyway/portaldb/V2.0.0__add-column-deletedat.sql create mode 100644 scripts/flyway/portaldb/V2.0.1__add-unique-key.sql diff --git a/scripts/docker-quick-start/sql/apolloconfigdb.sql b/scripts/docker-quick-start/sql/apolloconfigdb.sql index bc40f7179d6..3d25a99f559 100644 --- a/scripts/docker-quick-start/sql/apolloconfigdb.sql +++ b/scripts/docker-quick-start/sql/apolloconfigdb.sql @@ -41,12 +41,13 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_Name` (`Name`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表'; @@ -66,12 +67,13 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_AppId` (`AppId`), + UNIQUE KEY `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), KEY `Name_AppId` (`Name`,`AppId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义'; @@ -90,6 +92,7 @@ CREATE TABLE `Audit` ( `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT '操作类型', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -111,12 +114,13 @@ CREATE TABLE `Cluster` ( `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_AppId_Name` (`AppId`,`Name`), + UNIQUE KEY `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), KEY `IX_ParentClusterId` (`ParentClusterId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集群'; @@ -136,6 +140,7 @@ CREATE TABLE `Commit` ( `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName', `Comment` varchar(500) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -162,6 +167,7 @@ CREATE TABLE `GrayReleaseRule` ( `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '灰度对应的release', `BranchStatus` tinyint(2) DEFAULT '1' COMMENT '灰度分支状态: 0:删除分支,1:正在使用的规则 2:全量发布', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -230,6 +236,7 @@ CREATE TABLE `Item` ( `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `LineNum` int(10) unsigned DEFAULT '0' COMMENT '行号', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -252,12 +259,13 @@ CREATE TABLE `Namespace` ( `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name', `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId_ClusterName_NamespaceName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)), + UNIQUE KEY `UK_AppId_ClusterName_NamespaceName_DeletedAt` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191),`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_NamespaceName` (`NamespaceName`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='命名空间'; @@ -277,8 +285,9 @@ CREATE TABLE `NamespaceLock` ( `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', `IsDeleted` bit(1) DEFAULT b'0' COMMENT '软删除', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', PRIMARY KEY (`Id`), - UNIQUE KEY `IX_NamespaceId` (`NamespaceId`), + UNIQUE KEY `UK_NamespaceId_DeletedAt` (`NamespaceId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='namespace的编辑锁'; @@ -300,14 +309,15 @@ CREATE TABLE `Release` ( `Configurations` longtext NOT NULL COMMENT '发布配置', `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否废弃', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_ReleaseKey_DeletedAt` (`ReleaseKey`,`DeletedAt`), KEY `AppId_ClusterName_GroupName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)), - KEY `DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_ReleaseKey` (`ReleaseKey`) + KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='发布'; @@ -327,6 +337,7 @@ CREATE TABLE `ReleaseHistory` ( `Operation` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '发布类型,0: 普通发布,1: 回滚,2: 灰度发布,3: 灰度规则更新,4: 灰度合并回主分支发布,5: 主分支发布灰度自动发布,6: 主分支回滚灰度自动发布,7: 放弃灰度', `OperationContext` longtext NOT NULL COMMENT '发布上下文信息', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', @@ -366,12 +377,13 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_Key` (`Key`), + UNIQUE KEY `UK_Key_Cluster_DeletedAt` (`Key`,`Cluster`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; @@ -386,12 +398,13 @@ CREATE TABLE `AccessKey` ( `Secret` varchar(128) NOT NULL DEFAULT '' COMMENT 'Secret', `IsEnabled` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: enabled, 0: disabled', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_Secret_DeletedAt` (`AppId`,`Secret`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问密钥'; diff --git a/scripts/docker-quick-start/sql/apolloportaldb.sql b/scripts/docker-quick-start/sql/apolloportaldb.sql index ea1c08e2a53..54d27075364 100644 --- a/scripts/docker-quick-start/sql/apolloportaldb.sql +++ b/scripts/docker-quick-start/sql/apolloportaldb.sql @@ -41,12 +41,13 @@ CREATE TABLE `App` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`), KEY `IX_Name` (`Name`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表'; @@ -66,12 +67,13 @@ CREATE TABLE `AppNamespace` ( `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共', `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_AppId` (`AppId`), + UNIQUE KEY `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), KEY `Name_AppId` (`Name`,`AppId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义'; @@ -92,12 +94,13 @@ CREATE TABLE `Consumer` ( `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName', `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `AppId` (`AppId`(191)), + UNIQUE KEY `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开放API消费者'; @@ -132,14 +135,15 @@ CREATE TABLE `ConsumerRole` ( `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_ConsumerId_RoleId_DeletedAt` (`ConsumerId`,`RoleId`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_RoleId` (`RoleId`), - KEY `IX_ConsumerId_RoleId` (`ConsumerId`,`RoleId`) + KEY `IX_RoleId` (`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer和role的绑定表'; @@ -155,12 +159,13 @@ CREATE TABLE `ConsumerToken` ( `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token', `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - UNIQUE KEY `IX_Token` (`Token`), + UNIQUE KEY `UK_Token_DeletedAt` (`Token`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer token表'; @@ -175,13 +180,14 @@ CREATE TABLE `Favorite` ( `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID', `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_UserId_AppId_DeletedAt` (`UserId`,`AppId`,`DeletedAt`), KEY `AppId` (`AppId`(191)), - KEY `IX_UserId` (`UserId`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COMMENT='应用收藏表'; @@ -195,12 +201,13 @@ CREATE TABLE `Permission` ( `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型', `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_TargetId_PermissionType` (`TargetId`(191),`PermissionType`), + UNIQUE KEY `UK_TargetId_PermissionType_DeletedAt` (`TargetId`,`PermissionType`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='permission表'; @@ -215,12 +222,13 @@ CREATE TABLE `Role` ( `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id', `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_RoleName` (`RoleName`(191)), + UNIQUE KEY `UK_RoleName_DeletedAt` (`RoleName`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表'; @@ -236,13 +244,14 @@ CREATE TABLE `RolePermission` ( `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_RoleId_PermissionId_DeletedAt` (`RoleId`,`PermissionId`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_RoleId` (`RoleId`), KEY `IX_PermissionId` (`PermissionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和权限的绑定表'; @@ -259,12 +268,13 @@ CREATE TABLE `ServerConfig` ( `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值', `Comment` varchar(1024) DEFAULT '' COMMENT '注释', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), - KEY `IX_Key` (`Key`), + UNIQUE KEY `UK_Key_DeletedAt` (`Key`,`DeletedAt`), KEY `DataChange_LastTime` (`DataChange_LastTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置'; @@ -280,14 +290,15 @@ CREATE TABLE `UserRole` ( `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识', `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', + `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `DataChange_LastModifiedBy` varchar(64) DEFAULT '' COMMENT '最后修改人邮箱前缀', `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间', PRIMARY KEY (`Id`), + UNIQUE KEY `UK_UserId_RoleId_DeletedAt` (`UserId`,`RoleId`,`DeletedAt`), KEY `IX_DataChange_LastTime` (`DataChange_LastTime`), - KEY `IX_RoleId` (`RoleId`), - KEY `IX_UserId_RoleId` (`UserId`,`RoleId`) + KEY `IX_RoleId` (`RoleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和role的绑定表'; # Dump of table Users @@ -302,7 +313,8 @@ CREATE TABLE `Users` ( `UserDisplayName` varchar(512) NOT NULL DEFAULT 'default' COMMENT '用户名称', `Email` varchar(64) NOT NULL DEFAULT 'default' COMMENT '邮箱地址', `Enabled` tinyint(4) DEFAULT NULL COMMENT '是否有效', - PRIMARY KEY (`Id`) + PRIMARY KEY (`Id`), + UNIQUE KEY `UK_Username` (`Username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表'; diff --git a/scripts/flyway/configdb/V2.0.0__add-column-deletedat.sql b/scripts/flyway/configdb/V2.0.0__add-column-deletedat.sql new file mode 100644 index 00000000000..55708143923 --- /dev/null +++ b/scripts/flyway/configdb/V2.0.0__add-column-deletedat.sql @@ -0,0 +1,58 @@ +-- +-- Copyright 2022 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo config db from v1.9.0 to v2.0.0 + +Use ApolloConfigDB; + +ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Audit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Cluster` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Commit` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `GrayReleaseRule` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Item` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`, + ADD INDEX IX_key (`Key`); + +ALTER TABLE `Namespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `NamespaceLock` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Release` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ReleaseHistory` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AccessKey` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; diff --git a/scripts/flyway/configdb/V2.0.1__add-unique-key.sql b/scripts/flyway/configdb/V2.0.1__add-unique-key.sql new file mode 100644 index 00000000000..2d5c9d2a603 --- /dev/null +++ b/scripts/flyway/configdb/V2.0.1__add-unique-key.sql @@ -0,0 +1,76 @@ +-- +-- Copyright 2022 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo config db from v1.9.0 to v2.0.0 + +Use ApolloConfigDB; + +-- the follow DML won't change the `DataChange_LastTime` field +UPDATE `AccessKey` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `App` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AppNamespace` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Audit` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Cluster` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Commit` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `GrayReleaseRule` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Item` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Namespace` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `NamespaceLock` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Release` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ReleaseHistory` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ServerConfig` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; + +-- add UNIQUE CONSTRAINT INDEX for each table +ALTER TABLE `AccessKey` + ADD UNIQUE INDEX `UK_AppId_Secret_DeletedAt` (`AppId`,`Secret`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `App` + ADD UNIQUE INDEX `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `AppNamespace` + ADD UNIQUE INDEX `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), + DROP INDEX `IX_AppId`; + +-- Ignore TABLE `Audit` + +ALTER TABLE `Cluster` + ADD UNIQUE INDEX `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), + DROP INDEX `IX_AppId_Name`; + +-- Ignore TABLE `Commit` + +-- Ignore TABLE `GrayReleaseRule`, add unique index in future + +-- Ignore TABLE `Item`, add unique index in future + +ALTER TABLE `Namespace` + ADD UNIQUE INDEX `UK_AppId_ClusterName_NamespaceName_DeletedAt` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191),`DeletedAt`), + DROP INDEX `AppId_ClusterName_NamespaceName`; + +ALTER TABLE `NamespaceLock` + ADD UNIQUE INDEX `UK_NamespaceId_DeletedAt` (`NamespaceId`,`DeletedAt`), + DROP INDEX `IX_NamespaceId`; + +ALTER TABLE `Release` + ADD UNIQUE INDEX `UK_ReleaseKey_DeletedAt` (`ReleaseKey`,`DeletedAt`), + DROP INDEX `IX_ReleaseKey`; + +-- Ignore TABLE `ReleaseHistory` + +ALTER TABLE `ServerConfig` + ADD UNIQUE INDEX `UK_Key_Cluster_DeletedAt` (`Key`,`Cluster`,`DeletedAt`), + DROP INDEX `IX_Key`; diff --git a/scripts/flyway/portaldb/V2.0.0__add-column-deletedat.sql b/scripts/flyway/portaldb/V2.0.0__add-column-deletedat.sql new file mode 100644 index 00000000000..726270f6fe5 --- /dev/null +++ b/scripts/flyway/portaldb/V2.0.0__add-column-deletedat.sql @@ -0,0 +1,51 @@ +-- +-- Copyright 2022 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo portal db from v1.9.0 to v2.0.0 + +Use ApolloPortalDB; + +ALTER TABLE `App` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `AppNamespace` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Consumer` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ConsumerRole` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ConsumerToken` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Favorite` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Permission` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `Role` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `RolePermission` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `ServerConfig` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; + +ALTER TABLE `UserRole` + ADD COLUMN `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds' AFTER `IsDeleted`; \ No newline at end of file diff --git a/scripts/flyway/portaldb/V2.0.1__add-unique-key.sql b/scripts/flyway/portaldb/V2.0.1__add-unique-key.sql new file mode 100644 index 00000000000..444d6df762f --- /dev/null +++ b/scripts/flyway/portaldb/V2.0.1__add-unique-key.sql @@ -0,0 +1,79 @@ +-- +-- Copyright 2022 Apollo Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +# delta schema to upgrade apollo portal db from v1.9.0 to v2.0.0 + +Use ApolloPortalDB; + +-- the follow DML won't change the `DataChange_LastTime` field +UPDATE `App` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `AppNamespace` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Consumer` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ConsumerRole` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ConsumerToken` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Favorite` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Permission` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `Role` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `RolePermission` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `ServerConfig` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; +UPDATE `UserRole` SET `DeletedAt` = -Id, `DataChange_LastTime` = `DataChange_LastTime` WHERE `IsDeleted` = 1 and `DeletedAt` = 0; + +-- add UNIQUE CONSTRAINT INDEX for each table +ALTER TABLE `App` + ADD UNIQUE INDEX `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `AppNamespace` + ADD UNIQUE INDEX `UK_AppId_Name_DeletedAt` (`AppId`,`Name`,`DeletedAt`), + DROP INDEX `IX_AppId`; + +ALTER TABLE `Consumer` + ADD UNIQUE INDEX `UK_AppId_DeletedAt` (`AppId`,`DeletedAt`), + DROP INDEX `AppId`; + +ALTER TABLE `ConsumerRole` + ADD UNIQUE INDEX `UK_ConsumerId_RoleId_DeletedAt` (`ConsumerId`,`RoleId`,`DeletedAt`), + DROP INDEX `IX_ConsumerId_RoleId`; + +ALTER TABLE `ConsumerToken` + ADD UNIQUE INDEX `UK_Token_DeletedAt` (`Token`,`DeletedAt`), + DROP INDEX `IX_Token`; + +ALTER TABLE `Favorite` + ADD UNIQUE INDEX `UK_UserId_AppId_DeletedAt` (`UserId`,`AppId`,`DeletedAt`), + DROP INDEX `IX_UserId`; + +ALTER TABLE `Permission` + ADD UNIQUE INDEX `UK_TargetId_PermissionType_DeletedAt` (`TargetId`,`PermissionType`,`DeletedAt`), + DROP INDEX `IX_TargetId_PermissionType`; + +ALTER TABLE `Role` + ADD UNIQUE INDEX `UK_RoleName_DeletedAt` (`RoleName`,`DeletedAt`), + DROP INDEX `IX_RoleName`; + +ALTER TABLE `RolePermission` + ADD UNIQUE INDEX `UK_RoleId_PermissionId_DeletedAt` (`RoleId`,`PermissionId`,`DeletedAt`), + DROP INDEX `IX_RoleId`; + +ALTER TABLE `ServerConfig` + ADD UNIQUE INDEX `UK_Key_DeletedAt` (`Key`,`DeletedAt`), + DROP INDEX `IX_Key`; + +ALTER TABLE `UserRole` + ADD UNIQUE INDEX `UK_UserId_RoleId_DeletedAt` (`UserId`,`RoleId`,`DeletedAt`), + DROP INDEX `IX_UserId_RoleId`; + +ALTER TABLE `Users` + ADD UNIQUE INDEX `UK_Username` (`Username`); From c74cba3d65d21335a78309a89e6fa861e2051e55 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Mon, 14 Mar 2022 21:20:26 +0800 Subject: [PATCH 22/22] fix: set copyright 2022 --- apollo-adminservice/src/test/resources/import.sql | 2 +- apollo-biz/src/test/resources/import.sql | 2 +- .../java/com/ctrip/framework/apollo/common/jpa/H2Function.java | 2 +- .../common/jpa/SqlFunctionsMetadataBuilderContributor.java | 2 +- apollo-configservice/src/test/resources/import.sql | 2 +- apollo-portal/src/test/resources/import.sql | 2 +- scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql | 2 +- scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql | 2 +- scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql | 2 +- scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apollo-adminservice/src/test/resources/import.sql b/apollo-adminservice/src/test/resources/import.sql index 2fe5eb1d969..afd2dd89066 100644 --- a/apollo-adminservice/src/test/resources/import.sql +++ b/apollo-adminservice/src/test/resources/import.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/apollo-biz/src/test/resources/import.sql b/apollo-biz/src/test/resources/import.sql index 2fe5eb1d969..afd2dd89066 100644 --- a/apollo-biz/src/test/resources/import.sql +++ b/apollo-biz/src/test/resources/import.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java index 81199f6350a..2ca988a40b4 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/H2Function.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 Apollo Authors + * Copyright 2022 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java index 4bfb4fc3764..823faac65be 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/jpa/SqlFunctionsMetadataBuilderContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 Apollo Authors + * Copyright 2022 Apollo Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/apollo-configservice/src/test/resources/import.sql b/apollo-configservice/src/test/resources/import.sql index 2fe5eb1d969..afd2dd89066 100644 --- a/apollo-configservice/src/test/resources/import.sql +++ b/apollo-configservice/src/test/resources/import.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/apollo-portal/src/test/resources/import.sql b/apollo-portal/src/test/resources/import.sql index 2fe5eb1d969..afd2dd89066 100644 --- a/apollo-portal/src/test/resources/import.sql +++ b/apollo-portal/src/test/resources/import.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql index 286847ce1aa..2d5c9d2a603 100644 --- a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200-after.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql index afcee5d6fd0..55708143923 100644 --- a/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql +++ b/scripts/sql/delta/v190-v200/apolloconfigdb-v190-v200.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql index efdac97c652..444d6df762f 100644 --- a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql +++ b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200-after.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql index 0e6243c69f3..726270f6fe5 100644 --- a/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql +++ b/scripts/sql/delta/v190-v200/apolloportaldb-v190-v200.sql @@ -1,5 +1,5 @@ -- --- Copyright 2021 Apollo Authors +-- Copyright 2022 Apollo Authors -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License.