github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/pkg/meta/internal/sqlkv/model/model.go (about) 1 // Copyright 2022 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package sqlkv 15 16 import ( 17 metaModel "github.com/pingcap/tiflow/engine/pkg/meta/model" 18 ormModel "github.com/pingcap/tiflow/engine/pkg/orm/model" 19 ) 20 21 const ( 22 // MetaKVTableName is the explicitly defined table name for the metakv 23 // To avoid misinterpretation of table name when jobID is empty 24 MetaKVTableName = "meta_kvs" 25 ) 26 27 // 1. We use a cluster-specific schema(StoreConfig.Schema) to achieve cluster-level isolation 28 // 2. We use projectID to construct table name(e.g. $projectID_metakvs) to achieve project-level isolation 29 // 3. We use union columns <JobID, Key> of the metakv table as uk to achieve job-level isolation 30 31 // MetaKV is the model for business meta kv 32 // DON'T ADD soft-delete for metakv 33 type MetaKV struct { 34 ormModel.Model 35 metaModel.KeyValue 36 JobID metaModel.JobID `gorm:"column:job_id;type:varchar(64) not null;uniqueIndex:uidx_jk,priority:1"` 37 }