Skip to content

Commit

Permalink
feat: tenant version database upgrader
Browse files Browse the repository at this point in the history
--story=120234234
  • Loading branch information
Anna-shine committed Nov 26, 2024
1 parent ae5065c commit fd69318
Show file tree
Hide file tree
Showing 444 changed files with 11,710 additions and 2,405 deletions.
72 changes: 41 additions & 31 deletions src/common/index/collections/apitask.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,53 @@ func init() {
}

// TODO:
// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commAPITaskIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAPITaskIndexes = []types.Index{
//
// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commAPITaskIndexes = []types.Index{
{
Name: common.CCLogicUniqueIdxNamePrefix + "taskID",
Keys: bson.D{{"task_id", 1}},
Unique: true,
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: common.CCLogicIndexNamePrefix + "flag_status_createTime",
Keys: bson.D{{"flag", 1}, {"status", 1}, {"create_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: common.CCLogicIndexNamePrefix + "lastTime_status",
Keys: bson.D{{"last_time", 1}, {"status", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_taskID",
Keys: bson.D{{
"task_id", 1},
},
Unique: true,
Background: true,
Name: common.CCLogicIndexNamePrefix + "lastTime",
Keys: bson.D{{"last_time", 1}},
Background: false,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_name_status_createTime",
Keys: bson.D{
{"create_time", 1},
{"name", 1},
{"status", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "createTime_name_status",
Keys: bson.D{{"create_time", 1}, {"name", 1}, {"status", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_status_lastTime",
Keys: bson.D{
{"status", 1},
{"last_time", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "status_lastTime",
Keys: bson.D{{"status", 1}, {"last_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_name_flag_createTime",
Keys: bson.D{
{"name", 1},
{"flag", 1},
{"create_time", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "name_flag_createTime",
Keys: bson.D{{"name", 1}, {"flag", 1}, {"create_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAPITaskIndexes = []types.Index{}
57 changes: 29 additions & 28 deletions src/common/index/collections/applicationbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,41 @@ func init() {

}

// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commApplicationBaseIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedApplicationBaseIndexes = []types.Index{
// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commApplicationBaseIndexes = []types.Index{
{
Name: common.CCLogicIndexNamePrefix + "default",
Keys: bson.D{{"default", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "default_1",
Keys: bson.D{{
"default", 1},
},
Background: true,
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizName",
Keys: bson.D{{"bk_biz_name", 1}},
Unique: true,
Background: true,
PartialFilterExpression: map[string]interface{}{"bk_biz_name": map[string]string{common.BKDBType: "string"}},
},
{
Name: "bk_biz_id_1_bk_supplier_account_1",
Keys: bson.D{
{"bk_biz_id", 1},
{"bk_supplier_account", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount",
Keys: bson.D{{"bk_biz_id", 1}, {"bk_supplier_account", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "default_1_bk_supplier_account_1",
Keys: bson.D{
{"default", 1},
{"bk_supplier_account", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "default_bkSupplierAccount",
Keys: bson.D{{"default", 1}, {"bk_supplier_account", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_unique_bizID",
Keys: bson.D{
{"bk_biz_id", 1},
},
Unique: true,
Background: true,
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID",
Keys: bson.D{{"bk_biz_id", 1}},
Unique: true,
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedApplicationBaseIndexes = []types.Index{}
37 changes: 17 additions & 20 deletions src/common/index/collections/asstdes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,27 @@ func init() {
}

// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commAsstDesIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAsstDesIndexes = []types.Index{
var commAsstDesIndexes = []types.Index{
{
Name: "idx_unique_id",
Keys: bson.D{{
"id", 1},
},
Unique: true,
Background: true,
Name: common.CCLogicUniqueIdxNamePrefix + "ID",
Keys: bson.D{{"id", 1}},
Unique: true,
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_supplierId",
Keys: bson.D{{
"bk_supplier_account", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "bkAsstID",
Keys: bson.D{{"bk_asst_id", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_asstId",
Keys: bson.D{{
"bk_asst_id", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount",
Keys: bson.D{{"bk_supplier_account", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAsstDesIndexes = []types.Index{}
56 changes: 24 additions & 32 deletions src/common/index/collections/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,38 @@ func init() {

// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix

var commAuditLogIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAuditLogIndexes = []types.Index{
var commAuditLogIndexes = []types.Index{
{
Name: "index_id",
Keys: bson.D{{
"id", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "ID",
Keys: bson.D{{"id", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_operationTime",
Keys: bson.D{{
"operation_time", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "operationTime",
Keys: bson.D{{"operation_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_user",
Keys: bson.D{{
"user", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "user",
Keys: bson.D{{"user", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_resourceName",
Keys: bson.D{{
"resource_name", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "resourceName",
Keys: bson.D{{"resource_name", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_operationTime_auditType_resourceType_action",
Keys: bson.D{
{"audit_type", 1},
{"resource_type", 1},
{"action", 1},
{"operation_time", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "auditType_resourceName_action_operationTime",
Keys: bson.D{{"audit_type", 1}, {"resource_type", 1}, {"action", 1}, {"operation_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAuditLogIndexes = []types.Index{}
6 changes: 3 additions & 3 deletions src/common/index/collections/business_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ func init() {

var commBizSetIndexes = []types.Index{
{
Name: common.CCLogicUniqueIdxNamePrefix + "biz_set_id",
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetID",
Keys: bson.D{{
common.BKBizSetIDField, 1},
},
Unique: true,
Background: true,
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "biz_set_name",
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetName",
Keys: bson.D{{
common.BKBizSetNameField, 1},
},
Unique: true,
Background: true,
},
{
Name: common.CCLogicIndexNamePrefix + "biz_set_id_biz_set_name_owner_id",
Name: common.CCLogicIndexNamePrefix + "bkBizSetID_bkBizSetName_bkSupplierAccount",
Keys: bson.D{
{common.BKBizSetIDField, 1},
{common.BKBizSetNameField, 1},
Expand Down
Loading

0 comments on commit fd69318

Please sign in to comment.