meta

package
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright © 2020 Marvin

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayStructGroupsOf added in v1.0.12

func ArrayStructGroupsOf[T any](fsm []T, num int64) [][]T

Types

type BaseModel

type BaseModel struct {
	Comment   string    `gorm:"type:varchar(300);comment:comment content" json:"comment"`
	CreatedAt time.Time `gorm:"type:datetime(3) default current_timestamp(3);comment:'创建时间'" json:"createdAt"`
	UpdatedAt time.Time `gorm:"type:datetime(3) default current_timestamp(3) on update current_timestamp(3);comment:'更新时间'" json:"updatedAt"`
	*Meta     `gorm:"-" json:"-"`
}

BaseModel returns model struct base fields

func (*BaseModel) BeforeCreate

func (v *BaseModel) BeforeCreate(db *gorm.DB) (err error)

func (*BaseModel) BeforeUpdate

func (v *BaseModel) BeforeUpdate(db *gorm.DB) (err error)

type BuildinColumnDefaultval

type BuildinColumnDefaultval struct {
	ID            uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS       string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS   string `gorm:"type:varchar(200);index:idx_dbtype_st_map,unique;comment:'源数据库名'" json:"schema_name_s"`
	TableNameS    string `gorm:"type:varchar(200);index:idx_dbtype_st_map,unique;comment:'源数据库表名'" json:"table_name_s"`
	ColumnNameS   string `gorm:"type:varchar(200);index:idx_dbtype_st_map,unique;comment:'源数据库表字段名'" json:"column_name_s"`
	DefaultValueS string `gorm:"type:varchar(200);comment:'源端字段默认值'" json:"default_value_s"`
	DefaultValueT string `gorm:"type:varchar(200);not null;comment:'目标默认值'" json:"default_value_t"`
	*BaseModel
}

自定义字段默认值转换规则 - column 级别

func NewBuildinColumnDefaultvalModel

func NewBuildinColumnDefaultvalModel(m *Meta) *BuildinColumnDefaultval

func (*BuildinColumnDefaultval) CreateColumnDefaultVal

func (rw *BuildinColumnDefaultval) CreateColumnDefaultVal(ctx context.Context, createS *BuildinColumnDefaultval) error

func (*BuildinColumnDefaultval) DetailColumnDefaultVal

func (rw *BuildinColumnDefaultval) DetailColumnDefaultVal(ctx context.Context, detailS *BuildinColumnDefaultval) ([]BuildinColumnDefaultval, error)

func (*BuildinColumnDefaultval) ParseSchemaTable

func (rw *BuildinColumnDefaultval) ParseSchemaTable() (string, error)

type BuildinDatatypeRule

type BuildinDatatypeRule struct {
	ID            uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS       string `gorm:"type:varchar(30);index:idx_dbtype_st_obj,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(30);index:idx_dbtype_st_obj,unique;comment:'目标数据库类型'" json:"db_type_t"`
	DatatypeNameS string `gorm:"type:varchar(300);index:idx_dbtype_st_obj,unique;comment:'源数据类型名字'" json:"datatype_name_s"`
	DatatypeNameT string `gorm:"type:varchar(300);comment:'目标数据类型名字'" json:"datatype_name_t"`
	*BaseModel
}

func NewBuildinDatatypeRuleModel

func NewBuildinDatatypeRuleModel(m *Meta) *BuildinDatatypeRule

func (*BuildinDatatypeRule) BatchQueryBuildinDatatype

func (rw *BuildinDatatypeRule) BatchQueryBuildinDatatype(ctx context.Context, detailS *BuildinDatatypeRule) ([]BuildinDatatypeRule, error)

func (*BuildinDatatypeRule) InitM2OBuildinDatatypeRule

func (rw *BuildinDatatypeRule) InitM2OBuildinDatatypeRule(ctx context.Context) error

func (*BuildinDatatypeRule) InitO2MBuildinDatatypeRule

func (rw *BuildinDatatypeRule) InitO2MBuildinDatatypeRule(ctx context.Context) error

func (*BuildinDatatypeRule) InitO2TBuildinDatatypeRule added in v1.0.12

func (rw *BuildinDatatypeRule) InitO2TBuildinDatatypeRule(ctx context.Context) error

func (*BuildinDatatypeRule) InitT2OBuildinDatatypeRule added in v1.0.12

func (rw *BuildinDatatypeRule) InitT2OBuildinDatatypeRule(ctx context.Context) error

func (*BuildinDatatypeRule) ParseSchemaTable

func (rw *BuildinDatatypeRule) ParseSchemaTable() (string, error)

type BuildinGlobalDefaultval added in v1.0.9

type BuildinGlobalDefaultval struct {
	ID            uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS       string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	DefaultValueS string `gorm:"type:varchar(200);not null;index:idx_dbtype_st_map,unique;comment:'源端默认值'" json:"default_value_s"`
	DefaultValueT string `gorm:"type:varchar(200);not null;comment:'目标默认值'" json:"default_value_t"`
	*BaseModel
}

自定义字段默认值转换规则 - global 级别

func NewBuildinGlobalDefaultvalModel added in v1.0.9

func NewBuildinGlobalDefaultvalModel(m *Meta) *BuildinGlobalDefaultval

func (*BuildinGlobalDefaultval) CreateGlobalDefaultVal added in v1.0.9

func (rw *BuildinGlobalDefaultval) CreateGlobalDefaultVal(ctx context.Context, createS *BuildinGlobalDefaultval) error

func (*BuildinGlobalDefaultval) DetailGlobalDefaultVal added in v1.0.9

func (rw *BuildinGlobalDefaultval) DetailGlobalDefaultVal(ctx context.Context, detailS *BuildinGlobalDefaultval) ([]BuildinGlobalDefaultval, error)

func (*BuildinGlobalDefaultval) InitMT2OBuildinGlobalDefaultValue added in v1.0.12

func (rw *BuildinGlobalDefaultval) InitMT2OBuildinGlobalDefaultValue(ctx context.Context) error

func (*BuildinGlobalDefaultval) InitO2MTBuildinGlobalDefaultValue added in v1.0.12

func (rw *BuildinGlobalDefaultval) InitO2MTBuildinGlobalDefaultValue(ctx context.Context) error

func (*BuildinGlobalDefaultval) ParseSchemaTable added in v1.0.9

func (rw *BuildinGlobalDefaultval) ParseSchemaTable() (string, error)

func (*BuildinGlobalDefaultval) RowsAffected added in v1.0.9

func (rw *BuildinGlobalDefaultval) RowsAffected(ctx context.Context, defaultVal *BuildinGlobalDefaultval) int64

type BuildinObjectCompatible

type BuildinObjectCompatible struct {
	ID            uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS       string `gorm:"type:varchar(30);index:idx_dbtype_st_obj,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(30);index:idx_dbtype_st_obj,unique;comment:'目标数据库类型'" json:"db_type_t"`
	ObjectNameS   string `gorm:"type:varchar(300);index:idx_dbtype_st_obj,unique;comment:'源数据库对象名'" json:"object_name_s"`
	IsCompatible  string `gorm:"type:char(1);comment:'对象是否可兼容'" json:"is_compatible"`
	IsConvertible string `gorm:"type:char(1);comment:'对象是否可改造'" json:"is_convertible"`
	*BaseModel
}

func NewBuildinObjectCompatibleModel

func NewBuildinObjectCompatibleModel(m *Meta) *BuildinObjectCompatible

func (*BuildinObjectCompatible) BatchQueryObjAssessCompatible

func (rw *BuildinObjectCompatible) BatchQueryObjAssessCompatible(ctx context.Context, detailS *BuildinObjectCompatible) ([]BuildinObjectCompatible, error)

func (*BuildinObjectCompatible) InitO2MBuildinObjectCompatible

func (rw *BuildinObjectCompatible) InitO2MBuildinObjectCompatible(ctx context.Context) error

func (*BuildinObjectCompatible) InitO2TBuildinObjectCompatible added in v1.0.12

func (rw *BuildinObjectCompatible) InitO2TBuildinObjectCompatible(ctx context.Context) error

func (*BuildinObjectCompatible) ParseSchemaTable

func (rw *BuildinObjectCompatible) ParseSchemaTable() (string, error)

type ChunkErrorDetail added in v1.0.13

type ChunkErrorDetail struct {
	ID           uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS      string `gorm:"type:varchar(30);index:idx_dbtype_st_map;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT      string `gorm:"type:varchar(30);index:idx_dbtype_st_map;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS  string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS   string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT  string `gorm:"type:varchar(100);not null;comment:'目标端 schema'" json:"schema_name_t"`
	TableNameT   string `gorm:"type:varchar(100);not null;comment:'目标端表名'" json:"table_name_t"`
	TaskMode     string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map;comment:'任务模式'" json:"task_mode"`
	ChunkDetailS string `gorm:"type:varchar(300);not null;index:idx_dbtype_st_map;comment:'表 chunk 切分信息'" json:"chunk_detail_s"`
	InfoDetail   string `gorm:"type:longtext;not null;comment:'信息详情'" json:"info_detail"`
	ErrorSQL     string `gorm:"type:longtext;not null;comment:'错误 SQL'" json:"error_sql"`
	ErrorDetail  string `gorm:"type:longtext;not null;comment:'错误详情'" json:"error_detail"`
	*BaseModel
}

func NewChunkErrorDetailModel added in v1.0.13

func NewChunkErrorDetailModel(m *Meta) *ChunkErrorDetail

func (*ChunkErrorDetail) CreateChunkErrorDetail added in v1.0.13

func (rw *ChunkErrorDetail) CreateChunkErrorDetail(ctx context.Context, createS *ChunkErrorDetail) error

func (*ChunkErrorDetail) DeleteChunkErrorDetailBySchemaTaskMode added in v1.0.13

func (rw *ChunkErrorDetail) DeleteChunkErrorDetailBySchemaTaskMode(ctx context.Context, deleteS *ChunkErrorDetail) error

func (*ChunkErrorDetail) ParseSchemaTable added in v1.0.13

func (rw *ChunkErrorDetail) ParseSchemaTable() (string, error)

type ColumnDatatypeRule

type ColumnDatatypeRule struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端库 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	ColumnNameS string `gorm:"type:varchar(200);not null;index:idx_dbtype_st_map,unique;comment:'源端表字段列名'" json:"column_name_s"`
	ColumnTypeS string `gorm:"type:varchar(100);not null;comment:'源端表字段类型'" json:"column_type_s"`
	ColumnTypeT string `gorm:"type:varchar(100);not null;comment:'目标表字段类型'" json:"column_type_t"`
	*BaseModel
}
上下游字段类型映射表

数据类型转换优先级: column > table > schema > build-in 自定义列转换规则 - 字段列级别

func NewColumnDatatypeRuleModel

func NewColumnDatatypeRuleModel(m *Meta) *ColumnDatatypeRule

func (*ColumnDatatypeRule) CreateColumnRule

func (rw *ColumnDatatypeRule) CreateColumnRule(ctx context.Context, createS *ColumnDatatypeRule) error

func (*ColumnDatatypeRule) DetailColumnRule

func (rw *ColumnDatatypeRule) DetailColumnRule(ctx context.Context, detailS *ColumnDatatypeRule) ([]ColumnDatatypeRule, error)

func (*ColumnDatatypeRule) ParseSchemaTable

func (rw *ColumnDatatypeRule) ParseSchemaTable() (string, error)

type DataCompareMeta

type DataCompareMeta struct {
	ID            uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS       string `gorm:"type:varchar(30);index:idx_dbtype_st_obj,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(30);index:idx_dbtype_st_obj,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS   string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_obj,unique;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS    string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_obj,unique;comment:'源端表名'" json:"table_name_s"`
	ColumnDetailS string `gorm:"type:text;comment:'源端查询字段信息'" json:"column_detail_s"`
	SchemaNameT   string `gorm:"type:varchar(100);not null;comment:'目标端 schema'" json:"schema_name_t"`
	TableNameT    string `gorm:"type:varchar(100);not null;comment:'目标端表名'" json:"table_name_t"`
	ColumnDetailT string `gorm:"type:text;comment:'目标端查询字段信息'" json:"column_detail_t"`
	WhereColumn   string `gorm:"comment:'查询类型字段列'" json:"where_column"`
	WhereRange    string `gorm:"type:varchar(300);not null;index:idx_dbtype_st_obj,unique;comment:'查询 where 条件'" json:"where_range"`
	TaskMode      string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_obj,unique;comment:'任务模式'" json:"task_mode"`
	TaskStatus    string `gorm:"type:varchar(30);not null;comment:'数据对比状态,only waiting,success,failed'" json:"task_status"`
	IsPartition   string `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	InfoDetail    string `gorm:"type:text;not null;comment:'信息详情'" json:"info_detail"`
	ErrorDetail   string `gorm:"type:text;not null;comment:'错误详情'" json:"error_detail"`
	*BaseModel
}

数据校验元数据表

func NewDataCompareMetaModel

func NewDataCompareMetaModel(m *Meta) *DataCompareMeta

func (*DataCompareMeta) BatchCreateDataCompareMeta

func (rw *DataCompareMeta) BatchCreateDataCompareMeta(ctx context.Context, createS []DataCompareMeta, batchSize int) error

func (*DataCompareMeta) CountsDataCompareMetaByTaskTable added in v1.0.10

func (rw *DataCompareMeta) CountsDataCompareMetaByTaskTable(ctx context.Context, dataErr *DataCompareMeta) (int64, error)

func (*DataCompareMeta) CountsErrorDataCompareMeta added in v1.0.10

func (rw *DataCompareMeta) CountsErrorDataCompareMeta(ctx context.Context, dataErr *DataCompareMeta) (int64, error)

func (*DataCompareMeta) CreateDataCompareMeta

func (rw *DataCompareMeta) CreateDataCompareMeta(ctx context.Context, createS *DataCompareMeta) error

func (*DataCompareMeta) DetailDataCompareMeta

func (rw *DataCompareMeta) DetailDataCompareMeta(ctx context.Context, detailS *DataCompareMeta) ([]DataCompareMeta, error)

func (*DataCompareMeta) DistinctDataCompareMetaTableNameSByTaskStatus added in v1.0.10

func (rw *DataCompareMeta) DistinctDataCompareMetaTableNameSByTaskStatus(ctx context.Context, detailS *DataCompareMeta) ([]string, error)

func (*DataCompareMeta) ParseSchemaTable

func (rw *DataCompareMeta) ParseSchemaTable() (string, error)

func (*DataCompareMeta) TruncateDataCompareMeta

func (rw *DataCompareMeta) TruncateDataCompareMeta(ctx context.Context) error

func (*DataCompareMeta) UpdateDataCompareMeta added in v1.0.10

func (rw *DataCompareMeta) UpdateDataCompareMeta(ctx context.Context, deleteS *DataCompareMeta, updates map[string]interface{}) error

type ErrorLogDetail

type ErrorLogDetail struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(30);index:idx_dbtype_st_map;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(30);index:idx_dbtype_st_map;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map;comment:'目标端 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map;comment:'目标端表名'" json:"table_name_t"`
	TaskMode    string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map;comment:'任务模式'" json:"task_mode"`
	TaskStatus  string `gorm:"type:varchar(30);not null;comment:'任务状态'" json:"task_status"`
	SourceDDL   string `gorm:"type:longtext;not null;comment:'源端原始 DDL'" json:"source_ddl"`
	TargetDDL   string `gorm:"type:longtext;not null;comment:'目标端转换 DDL'" json:"target_ddl"`
	InfoDetail  string `gorm:"type:longtext;not null;comment:'信息详情'" json:"info_detail"`
	ErrorDetail string `gorm:"type:longtext;not null;comment:'错误详情'" json:"error_detail"`
	*BaseModel
}

func NewErrorLogDetailModel

func NewErrorLogDetailModel(m *Meta) *ErrorLogDetail

func (*ErrorLogDetail) CountsErrorLogBySchema

func (rw *ErrorLogDetail) CountsErrorLogBySchema(ctx context.Context, detailS *ErrorLogDetail) (int64, error)

func (*ErrorLogDetail) CreateErrorLog

func (rw *ErrorLogDetail) CreateErrorLog(ctx context.Context, createS *ErrorLogDetail) error

func (*ErrorLogDetail) DetailErrorLog

func (rw *ErrorLogDetail) DetailErrorLog(ctx context.Context, detailS *ErrorLogDetail) ([]ErrorLogDetail, error)

func (*ErrorLogDetail) ParseSchemaTable

func (rw *ErrorLogDetail) ParseSchemaTable() (string, error)

type FullSyncMeta

type FullSyncMeta struct {
	ID            uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS       string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;index:idx_schema_mode;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;index:idx_schema_mode;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS   string `` /* 131-byte string literal not displayed */
	TableNameS    string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT   string `gorm:"type:varchar(100);not null;comment:'目标端 schema'" json:"schema_name_t"`
	TableNameT    string `gorm:"type:varchar(100);not null;comment:'目标端表名'" json:"table_name_t"`
	GlobalScnS    uint64 `gorm:"comment:'源端全局 SCN'" json:"global_scn_s"`
	ColumnDetailS string `gorm:"type:text;comment:'源端查询字段信息'" json:"column_detail_s"`
	ChunkDetailS  string `gorm:"type:varchar(300);not null;index:idx_dbtype_st_map,unique;comment:'表 chunk 切分信息'" json:"chunk_detail_s"`
	TaskMode      string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;index:idx_schema_mode;comment:'任务模式'" json:"task_mode"`
	TaskStatus    string `gorm:"type:varchar(30);not null;comment:'任务 chunk 状态'" json:"task_status"`
	CSVFile       string `gorm:"type:varchar(300);comment:'csv 文件名'" json:"csv_file"`
	*BaseModel
}

全量同步元数据表

func NewFullSyncMetaModel

func NewFullSyncMetaModel(m *Meta) *FullSyncMeta

func (*FullSyncMeta) BatchCreateFullSyncMeta

func (rw *FullSyncMeta) BatchCreateFullSyncMeta(ctx context.Context, createS []FullSyncMeta, batchSize int) error

func (*FullSyncMeta) CountsErrorFullSyncMeta added in v1.0.10

func (rw *FullSyncMeta) CountsErrorFullSyncMeta(ctx context.Context, dataErr *FullSyncMeta) (int64, error)

func (*FullSyncMeta) CountsFullSyncMetaByTaskTable added in v1.0.10

func (rw *FullSyncMeta) CountsFullSyncMetaByTaskTable(ctx context.Context, dataErr *FullSyncMeta) (int64, error)

func (*FullSyncMeta) DeleteFullSyncMetaBySchemaSyncMode

func (rw *FullSyncMeta) DeleteFullSyncMetaBySchemaSyncMode(ctx context.Context, deleteS *FullSyncMeta) error

func (*FullSyncMeta) DeleteFullSyncMetaBySchemaTableChunk added in v1.0.13

func (rw *FullSyncMeta) DeleteFullSyncMetaBySchemaTableChunk(ctx context.Context, deleteS *FullSyncMeta) error

func (*FullSyncMeta) DetailFullSyncMeta

func (rw *FullSyncMeta) DetailFullSyncMeta(ctx context.Context, detailS *FullSyncMeta) ([]FullSyncMeta, error)

func (*FullSyncMeta) ParseSchemaTable

func (rw *FullSyncMeta) ParseSchemaTable() (string, error)

func (*FullSyncMeta) String

func (rw *FullSyncMeta) String() string

func (*FullSyncMeta) UpdateFullSyncMetaChunk added in v1.0.13

func (rw *FullSyncMeta) UpdateFullSyncMetaChunk(ctx context.Context, detailS *FullSyncMeta, updates map[string]interface{}) error

type IncrSyncMeta

type IncrSyncMeta struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'目标 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'目标表名'" json:"table_name_t"`
	GlobalScnS  uint64 `gorm:"comment:'源端全局 SCN'" json:"global_scn_s"`
	TableScnS   uint64 `gorm:"comment:'源端表同步 SCN'" json:"table_scn_s"`
	IsPartition string `gorm:"type:varchar(10);comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	*BaseModel
}

增量同步元数据表

func NewIncrSyncMetaModel

func NewIncrSyncMetaModel(m *Meta) *IncrSyncMeta

func (*IncrSyncMeta) BatchCreateIncrSyncMeta

func (rw *IncrSyncMeta) BatchCreateIncrSyncMeta(ctx context.Context, createS []IncrSyncMeta, batchSize int) error

func (*IncrSyncMeta) CountsIncrSyncMetaBySchemaTable

func (rw *IncrSyncMeta) CountsIncrSyncMetaBySchemaTable(ctx context.Context, detailS *IncrSyncMeta) (int64, error)

func (*IncrSyncMeta) DetailIncrSyncMetaBySchema

func (rw *IncrSyncMeta) DetailIncrSyncMetaBySchema(ctx context.Context, detailS *IncrSyncMeta) ([]IncrSyncMeta, error)

func (*IncrSyncMeta) GetIncrSyncMetaMinGlobalScnSBySchema

func (rw *IncrSyncMeta) GetIncrSyncMetaMinGlobalScnSBySchema(ctx context.Context, detailS *IncrSyncMeta) (uint64, error)

func (*IncrSyncMeta) GetIncrSyncMetaMinTableScnSBySchema

func (rw *IncrSyncMeta) GetIncrSyncMetaMinTableScnSBySchema(ctx context.Context, detailS *IncrSyncMeta) (uint64, error)

func (*IncrSyncMeta) ParseSchemaTable

func (rw *IncrSyncMeta) ParseSchemaTable() (string, error)

func (*IncrSyncMeta) UpdateIncrSyncMeta

func (rw *IncrSyncMeta) UpdateIncrSyncMeta(ctx context.Context, detailS *IncrSyncMeta) error

type Meta

type Meta struct {
	GormDB *gorm.DB
}

func NewMetaDBEngine

func NewMetaDBEngine(ctx context.Context, mysqlCfg config.MetaConfig, slowThreshold int) (*Meta, error)

func WrapGormDB

func WrapGormDB(gormDB *gorm.DB) *Meta

func (*Meta) DB

func (m *Meta) DB(ctx context.Context) *gorm.DB

func (*Meta) InitDefaultValue

func (m *Meta) InitDefaultValue(ctx context.Context) error

func (*Meta) MigrateTables

func (m *Meta) MigrateTables() (err error)

type SchemaDatatypeRule

type SchemaDatatypeRule struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"type:varchar(200);not null;index:idx_dbtype_st_map,unique;comment:'源端库 schema'" json:"schema_name_s"`
	ColumnTypeS string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端表字段类型'" json:"column_type_s"`
	ColumnTypeT string `gorm:"type:varchar(100);not null;comment:'目标表字段类型'" json:"column_type_t"`
	*BaseModel
}

自定义库转换规则 - schema 级别

func NewSchemaDatatypeRuleModel

func NewSchemaDatatypeRuleModel(m *Meta) *SchemaDatatypeRule

func (*SchemaDatatypeRule) DetailSchemaRule

func (rw *SchemaDatatypeRule) DetailSchemaRule(ctx context.Context, detailS *SchemaDatatypeRule) ([]SchemaDatatypeRule, error)

func (*SchemaDatatypeRule) ParseSchemaTable

func (rw *SchemaDatatypeRule) ParseSchemaTable() (string, error)

type TableDatatypeRule

type TableDatatypeRule struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"type:varchar(200);not null;index:idx_dbtype_st_map,unique;comment:'源端库 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"type:varchar(200);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	ColumnTypeS string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端表字段类型'" json:"column_type_s"`
	ColumnTypeT string `gorm:"type:varchar(100);not null;comment:'目标表字段类型'" json:"column_type_t"`
	*BaseModel
}

自定义表转换规则 - table 级别

func NewTableDatatypeRuleModel

func NewTableDatatypeRuleModel(m *Meta) *TableDatatypeRule

func (*TableDatatypeRule) DetailTableRule

func (rw *TableDatatypeRule) DetailTableRule(ctx context.Context, detailS *TableDatatypeRule) ([]TableDatatypeRule, error)

func (*TableDatatypeRule) ParseSchemaTable

func (rw *TableDatatypeRule) ParseSchemaTable() (string, error)

type TableNameRule

type TableNameRule struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `` /* 133-byte string literal not displayed */
	DBTypeT     string `` /* 136-byte string literal not displayed */
	SchemaNameS string `` /* 145-byte string literal not displayed */
	TableNameS  string `` /* 140-byte string literal not displayed */
	SchemaNameT string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'目标库 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"type:varchar(100);not null;comment:'目标表名'" json:"table_name_t"`
	*BaseModel
}

上下游数据表名字映射规则

func NewTableNameRuleModel

func NewTableNameRuleModel(m *Meta) *TableNameRule

func (*TableNameRule) DetailTableNameRule

func (rw *TableNameRule) DetailTableNameRule(ctx context.Context, detailS *TableNameRule) ([]TableNameRule, error)

func (*TableNameRule) ParseSchemaTable

func (rw *TableNameRule) ParseSchemaTable() (string, error)

type Transaction

type Transaction struct {
	*Meta
}

func NewCommonModel

func NewCommonModel(m *Meta) *Transaction

func (*Transaction) BatchCreateDataCompareMetaAndUpdateWaitSyncMeta added in v1.0.10

func (rw *Transaction) BatchCreateDataCompareMetaAndUpdateWaitSyncMeta(ctx context.Context, dataMeta []DataCompareMeta, batchSize int, waitSyncMeta *WaitSyncMeta) error

func (*Transaction) BatchCreateFullSyncMetaAndUpdateWaitSyncMeta added in v1.0.10

func (rw *Transaction) BatchCreateFullSyncMetaAndUpdateWaitSyncMeta(ctx context.Context, dataMeta []FullSyncMeta, batchSize int, waitSyncMeta *WaitSyncMeta) error

func (*Transaction) CreateDataCompareMetaAndUpdateWaitSyncMeta

func (rw *Transaction) CreateDataCompareMetaAndUpdateWaitSyncMeta(ctx context.Context, dataDiffMeta *DataCompareMeta, waitSyncMeta *WaitSyncMeta) error

func (*Transaction) CreateErrorDetailAndUpdateWaitSyncMetaTaskStatus added in v1.0.10

func (rw *Transaction) CreateErrorDetailAndUpdateWaitSyncMetaTaskStatus(ctx context.Context, errLogDetail *ErrorLogDetail, waitSyncMeta *WaitSyncMeta) error

func (*Transaction) CreateFullSyncMetaAndUpdateWaitSyncMeta

func (rw *Transaction) CreateFullSyncMetaAndUpdateWaitSyncMeta(ctx context.Context, fullSyncMeta *FullSyncMeta, waitSyncMeta *WaitSyncMeta) error

func (*Transaction) DeleteIncrSyncMetaAndWaitSyncMeta

func (rw *Transaction) DeleteIncrSyncMetaAndWaitSyncMeta(ctx context.Context, incrSyncMeta *IncrSyncMeta, waitSyncMeta *WaitSyncMeta) error

func (*Transaction) DeleteTableDataCompareMetaAndUpdateWaitSyncMeta added in v1.0.10

func (rw *Transaction) DeleteTableDataCompareMetaAndUpdateWaitSyncMeta(ctx context.Context, deleteS *DataCompareMeta, updateS *WaitSyncMeta) error

func (*Transaction) DeleteTableFullSyncMetaAndUpdateWaitSyncMeta added in v1.0.10

func (rw *Transaction) DeleteTableFullSyncMetaAndUpdateWaitSyncMeta(ctx context.Context, deleteS *FullSyncMeta, updateS *WaitSyncMeta) error

func (*Transaction) UpdateFullSyncMetaChunkAndCreateChunkErrorDetail added in v1.0.13

func (rw *Transaction) UpdateFullSyncMetaChunkAndCreateChunkErrorDetail(ctx context.Context, detailS *FullSyncMeta,
	updateS map[string]interface{}, chunkErrorS *ChunkErrorDetail) error

func (*Transaction) UpdateIncrSyncMetaSCNByArchivedLog

func (rw *Transaction) UpdateIncrSyncMetaSCNByArchivedLog(ctx context.Context,
	dbTypeS, dbTypeT, sourceSchemaName string, logFileEndSCN uint64, transferTableSlice []string) error

func (*Transaction) UpdateIncrSyncMetaSCNByCurrentRedo

func (rw *Transaction) UpdateIncrSyncMetaSCNByCurrentRedo(ctx context.Context,
	dbTypeS, dbTypeT, sourceSchemaName string, lastRedoLogMaxSCN, logFileStartSCN, logFileEndSCN uint64) error

func (*Transaction) UpdateIncrSyncMetaSCNByNonCurrentRedo

func (rw *Transaction) UpdateIncrSyncMetaSCNByNonCurrentRedo(ctx context.Context,
	dbTypeS, dbTypeT, sourceSchemaName string, lastRedoLogMaxSCN, logFileStartSCN, logFileEndSCN uint64, transferTableSlice []string) error

type WaitSyncMeta

type WaitSyncMeta struct {
	ID               uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS          string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT          string `gorm:"type:varchar(30);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS      string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS       string `gorm:"type:varchar(100);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	TaskMode         string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;comment:'任务模式'" json:"task_mode"`
	TaskStatus       string `gorm:"type:varchar(30);not null;comment:'任务状态'" json:"task_status"`
	GlobalScnS       uint64 `gorm:"comment:'全量任务 full_sync_meta 全局 SCN'" json:"global_scn_s"`
	TableNumRows     uint64 `gorm:"comment:'全量任务源端表数据行数'" json:"table_num_rows"`
	ChunkTotalNums   int64  `gorm:"comment:'全量任务 full_sync_meta 任务切分 chunk 数'" json:"chunk_total_nums"`
	ChunkSuccessNums int64  `gorm:"comment:'全量任务 full_sync_meta 执行成功 chunk 数'" json:"chunk_success_nums"`
	ChunkFailedNums  int64  `gorm:"comment:'全量任务 full_sync_meta 执行失败 chunk 数'" json:"chunk_failed_nums"`
	IsPartition      string `gorm:"type:varchar(10);comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	*BaseModel
}

同步元数据表

func NewWaitSyncMetaModel

func NewWaitSyncMetaModel(m *Meta) *WaitSyncMeta

func (*WaitSyncMeta) CountsErrWaitSyncMetaBySchema added in v1.0.10

func (rw *WaitSyncMeta) CountsErrWaitSyncMetaBySchema(ctx context.Context, dataErr *WaitSyncMeta) (int64, error)

func (*WaitSyncMeta) CreateWaitSyncMeta

func (rw *WaitSyncMeta) CreateWaitSyncMeta(ctx context.Context, createS *WaitSyncMeta) error

func (*WaitSyncMeta) DeleteWaitSyncMeta

func (rw *WaitSyncMeta) DeleteWaitSyncMeta(ctx context.Context, deleteS *WaitSyncMeta) error

func (*WaitSyncMeta) DeleteWaitSyncMetaSuccessTables added in v1.0.10

func (rw *WaitSyncMeta) DeleteWaitSyncMetaSuccessTables(ctx context.Context, deleteS *WaitSyncMeta, tables []string) error

func (*WaitSyncMeta) DetailWaitSyncMeta

func (rw *WaitSyncMeta) DetailWaitSyncMeta(ctx context.Context, detailS *WaitSyncMeta) ([]WaitSyncMeta, error)

func (*WaitSyncMeta) DetailWaitSyncMetaBySchema

func (rw *WaitSyncMeta) DetailWaitSyncMetaBySchema(ctx context.Context, detailS *WaitSyncMeta) ([]WaitSyncMeta, error)

func (*WaitSyncMeta) DetailWaitSyncMetaBySchemaTableSCN

func (rw *WaitSyncMeta) DetailWaitSyncMetaBySchemaTableSCN(ctx context.Context, detailS *WaitSyncMeta) ([]WaitSyncMeta, error)

func (*WaitSyncMeta) DetailWaitSyncMetaSuccessTables added in v1.0.10

func (rw *WaitSyncMeta) DetailWaitSyncMetaSuccessTables(ctx context.Context, detailS *WaitSyncMeta) ([]string, error)

func (*WaitSyncMeta) ParseSchemaTable

func (rw *WaitSyncMeta) ParseSchemaTable() (string, error)

func (*WaitSyncMeta) QueryWaitSyncMetaByPartTask added in v1.0.10

func (rw *WaitSyncMeta) QueryWaitSyncMetaByPartTask(ctx context.Context, queryS *WaitSyncMeta) ([]WaitSyncMeta, error)

func (*WaitSyncMeta) UpdateWaitSyncMeta

func (rw *WaitSyncMeta) UpdateWaitSyncMeta(ctx context.Context, detailS *WaitSyncMeta, updates map[string]interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL