meta

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: Apache-2.0 Imports: 14 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	Comment   string    `gorm:"type:varchar(1000);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(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS   string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'源数据库名'" json:"schema_name_s"`
	TableNameS    string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'源数据库表名'" json:"table_name_s"`
	ColumnNameS   string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'源数据库表字段名'" json:"column_name_s"`
	DefaultValueS string `gorm:"type:varchar(30);comment:'源端字段默认值'" json:"default_value_s"`
	DefaultValueT string `gorm:"type:varchar(30);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(15);index:idx_dbtype_st_obj,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(15);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) 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(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	DefaultValueS string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;comment:'源端默认值'" json:"default_value_s"`
	DefaultValueT string `gorm:"type:varchar(30);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) InitM2OBuildinGlobalDefaultValue added in v1.0.9

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

func (*BuildinGlobalDefaultval) InitO2MBuildinGlobalDefaultValue added in v1.0.9

func (rw *BuildinGlobalDefaultval) InitO2MBuildinGlobalDefaultValue(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(15);index:idx_dbtype_st_obj,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT       string `gorm:"type:varchar(15);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) ParseSchemaTable

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

type ColumnDatatypeRule

type ColumnDatatypeRule struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端库 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	ColumnNameS string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端表字段列名'" json:"column_name_s"`
	ColumnTypeS string `gorm:"not null;comment:'源端表字段类型'" json:"column_type_s"`
	ColumnTypeT string `gorm:"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(15);index:idx_dbtype_st_obj,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_obj,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"not null;index:idx_dbtype_st_obj,unique;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"not null;index:idx_dbtype_st_obj,unique;comment:'源端表名'" json:"table_name_s"`
	ColumnInfoS string `gorm:"type:text;comment:'源端查询字段信息'" json:"column_info_s"`
	SchemaNameT string `gorm:"not null;comment:'目标端 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"not null;comment:'目标端表名'" json:"table_name_t"`
	ColumnInfoT string `gorm:"type:text;comment:'目标端查询字段信息'" json:"column_info_t"`
	WhereColumn string `gorm:"comment:'查询类型字段列'" json:"where_column"`
	WhereRange  string `gorm:"not null;index:idx_dbtype_st_obj,unique;comment:'查询 where 条件'" json:"where_range"`
	IsPartition string `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	*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) CreateDataCompareMeta

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

func (*DataCompareMeta) DeleteDataCompareMeta

func (rw *DataCompareMeta) DeleteDataCompareMeta(ctx context.Context, deleteS *DataCompareMeta) error

func (*DataCompareMeta) DetailDataCompareMeta

func (rw *DataCompareMeta) DetailDataCompareMeta(ctx context.Context, detailS *DataCompareMeta) (interface{}, error)

func (*DataCompareMeta) DistinctDataCompareMetaTableNameS

func (rw *DataCompareMeta) DistinctDataCompareMetaTableNameS(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

type ErrorLogDetail

type ErrorLogDetail struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(15);index:idx_dbtype_st_map;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_map;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"not null;index:idx_dbtype_st_map;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"not null;index:idx_dbtype_st_map;comment:'源端表名'" json:"table_name_s"`
	RunMode     string `gorm:"not null;index:idx_dbtype_st_map;comment:'运行模式'" json:"run_mode"`
	RunStatus   string `gorm:"not null;comment:'运行状态'" json:"run_status"`
	InfoDetail  string `gorm:"not null;comment:'信息详情'" json:"info_detail"`
	ErrorDetail string `gorm:"not null;comment:'错误详情'" json:"error_detail"`
	*BaseModel
}

表错误详情 用于 reverse 和 check 模式

func NewErrorLogDetailModel

func NewErrorLogDetailModel(m *Meta) *ErrorLogDetail

func (*ErrorLogDetail) CountsErrorLogBySchema

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

func (*ErrorLogDetail) CountsErrorLogBySchemaTable

func (rw *ErrorLogDetail) CountsErrorLogBySchemaTable(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(15);index:idx_dbtype_st_map,unique;index:idx_schema_mode;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;index:idx_schema_mode;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `` /* 130-byte string literal not displayed */
	TableNameS  string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT string `gorm:"type:varchar(15);not null;comment:'目标端 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"type:varchar(30);not null;comment:'目标端表名'" json:"table_name_t"`
	GlobalScnS  uint64 `gorm:"comment:'源端全局 SCN'" json:"global_scn_s"`
	ColumnInfoS string `gorm:"type:text;comment:'源端查询字段信息'" json:"column_info_s"`
	RowidInfoS  string `gorm:"type:varchar(300);not null;index:idx_dbtype_st_map,unique;comment:'表 rowid 切分信息'" json:"rowid_info_s"`
	Mode        string `gorm:"not null;index:idx_dbtype_st_map,unique;index:idx_schema_mode;comment:'同步模式'" json:"mode"`
	IsPartition string `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	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) DeleteFullSyncMetaBySchemaSyncMode

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

func (*FullSyncMeta) DeleteFullSyncMetaBySchemaTableRowid

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

清理并更新同步任务元数据表 1、全量每成功同步一张表记录,再清理记录 2、更新同步数据表元信息

func (*FullSyncMeta) DetailFullSyncMeta

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

func (*FullSyncMeta) DistinctFullSyncMetaByTableNameS

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

func (*FullSyncMeta) ParseSchemaTable

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

func (*FullSyncMeta) String

func (rw *FullSyncMeta) String() string

type IncrSyncMeta

type IncrSyncMeta struct {
	ID          uint   `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	DBTypeS     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT string `gorm:"type:varchar(30);not null;index:idx_dbtype_st_map,unique;comment:'目标 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"type:varchar(30);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:"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.MySQLConfig, 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(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端库 schema'" json:"schema_name_s"`
	ColumnTypeS string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端表字段类型'" json:"column_type_s"`
	ColumnTypeT string `gorm:"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(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT     string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端库 schema'" json:"schema_name_s"`
	TableNameS  string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	ColumnTypeS string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端表字段类型'" json:"column_type_s"`
	ColumnTypeT string `gorm:"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 `` /* 127-byte string literal not displayed */
	TableNameS  string `gorm:"not null;index:idx_dbtype_st_map,unique;index:idx_dbtype_st_table,unique;comment:'源端表名'" json:"table_name_s"`
	SchemaNameT string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'目标库 schema'" json:"schema_name_t"`
	TableNameT  string `gorm:"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) CreateDataCompareMetaAndUpdateWaitSyncMeta

func (rw *Transaction) CreateDataCompareMetaAndUpdateWaitSyncMeta(ctx context.Context, dataDiffMeta *DataCompareMeta, 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) 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(15);index:idx_dbtype_st_map,unique;comment:'源数据库类型'" json:"db_type_s"`
	DBTypeT        string `gorm:"type:varchar(15);index:idx_dbtype_st_map,unique;comment:'目标数据库类型'" json:"db_type_t"`
	SchemaNameS    string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端 schema'" json:"schema_name_s"`
	TableNameS     string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'源端表名'" json:"table_name_s"`
	Mode           string `gorm:"not null;index:idx_dbtype_st_map,unique;comment:'同步模式'" json:"mode"`
	FullGlobalSCN  uint64 `gorm:"comment:'全量任务 full_sync_meta 全局 SCN'" json:"full_global_scn"`
	FullSplitTimes int    `gorm:"comment:'全量任务 full_sync_meta 切分 SQL 次数'" json:"full_split_times"`
	IsPartition    string `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	*BaseModel
}

同步元数据表

func NewWaitSyncMetaModel

func NewWaitSyncMetaModel(m *Meta) *WaitSyncMeta

func (*WaitSyncMeta) BatchQueryWaitSyncMeta

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

Query returns part sync meta records

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) DetailWaitSyncMeta

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

Detail returns wait sync meta records

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) ModifyWaitSyncMetaColumnFullSplitTimesZero

func (rw *WaitSyncMeta) ModifyWaitSyncMetaColumnFullSplitTimesZero(ctx context.Context, detailS *WaitSyncMeta) error

func (*WaitSyncMeta) ParseSchemaTable

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

func (*WaitSyncMeta) UpdateWaitSyncMeta

func (rw *WaitSyncMeta) UpdateWaitSyncMeta(ctx context.Context, detailS *WaitSyncMeta) error

Jump to

Keyboard shortcuts

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