o2m

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 20 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 r. 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 r. 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 FilterOracleCompatibleTable added in v1.0.9

func FilterOracleCompatibleTable(cfg *config.Config, oracle *oracle.Oracle, exporters []string) ([]string, []string, []string, []string, []string, error)

func GenCompatibilityTable

func GenCompatibilityTable(f *reverse.Write, sourceSchema string, partitionTables, temporaryTables, clusteredTables []string, materializedViews []string) error

func GenCreateSchema

func GenCreateSchema(w *reverse.Write, sourceSchema, targetSchema, nlsComp string, directWrite bool) error

func IChanger added in v1.0.8

func IChanger(c reverse.Changer) (map[string]string, map[string]map[string]string, map[string]map[string]string, error)

func IWriter

func IWriter(w *reverse.Write, iw reverse.Writer) (string, error)

func LoadColumnDefaultValueRule added in v1.0.8

func LoadColumnDefaultValueRule(columnName, defaultValue string, defaultValueColumnMapSlice []meta.BuildinColumnDefaultval, defaultValueGlobalMapSlice []meta.BuildinGlobalDefaultval) string

func LoadColumnTypeRuleOnlyUsingColumn added in v1.0.8

func LoadColumnTypeRuleOnlyUsingColumn(columnName string, originColumnType string, buildInColumnType string, columnDataTypeMapSlice []meta.ColumnDatatypeRule) string

字段级别自定义映射规则

func LoadDataTypeRuleUsingTableOrSchema added in v1.0.8

func LoadDataTypeRuleUsingTableOrSchema(originColumnType string, buildInColumnType string, tableDataTypeMapSlice []meta.TableDatatypeRule,
	schemaDataTypeMapSlice []meta.SchemaDatatypeRule) string

func OracleTableColumnMapRule

func OracleTableColumnMapRule(sourceSchema, sourceTable string, column Column, buildinDatatypes []meta.BuildinDatatypeRule) (string, string, error)

Types

type Change added in v1.0.8

type Change struct {
	Ctx              context.Context `json:"-"`
	DBTypeS          string          `json:"db_type_s"`
	DBTypeT          string          `json:"db_type_t"`
	SourceSchemaName string          `json:"source_schema_name"`
	TargetSchemaName string          `json:"target_schema_name"`
	SourceTables     []string        `json:"source_tables"`
	Threads          int             `json:"threads"`
	OracleCollation  bool            `json:"oracle_collation"`
	Oracle           *oracle.Oracle  `json:"-"`
	MetaDB           *meta.Meta      `json:"-"`
}

func (*Change) ChangeTableColumnDatatype added in v1.0.8

func (r *Change) ChangeTableColumnDatatype() (map[string]map[string]string, error)

数据库查询获取自定义表结构转换规则 加载数据类型转换规则【处理字段级别、表级别、库级别数据类型映射规则】 数据类型转换规则判断,未设置自定义规则,默认采用内置默认字段类型转换

func (*Change) ChangeTableColumnDefaultValue added in v1.0.8

func (r *Change) ChangeTableColumnDefaultValue() (map[string]map[string]string, error)

func (*Change) ChangeTableName added in v1.0.8

func (r *Change) ChangeTableName() (map[string]string, error)

type Column added in v1.0.8

type Column struct {
	DataType                string
	CharLength              string
	CharUsed                string
	CharacterSet            string
	Collation               string
	OracleOriginDataDefault string
	MySQLOriginDataDefault  string
	ColumnInfo
}

type ColumnInfo added in v1.0.8

type ColumnInfo struct {
	DataLength        string
	DataPrecision     string
	DataScale         string
	DatetimePrecision string
	NULLABLE          string
	DataDefault       string
	Comment           string
}

type DDL

type DDL struct {
	SourceSchemaName   string   `json:"source_schema"`
	SourceTableName    string   `json:"source_table_name"`
	SourceTableType    string   `json:"source_table_type"`
	SourceTableDDL     string   `json:"-"` // 忽略
	TargetSchemaName   string   `json:"target_schema"`
	TargetTableName    string   `json:"target_table_name"`
	TargetDBType       string   `json:"target_db_type"`
	TargetDBVersion    string   `json:"target_db_version"`
	TablePrefix        string   `json:"table_prefix"`
	TableColumns       []string `json:"table_columns"`
	TableKeys          []string `json:"table_keys"`
	TableSuffix        string   `json:"table_suffix"`
	TableComment       string   `json:"table_comment"`
	TableCheckKeys     []string `json:"table_check_keys""`
	TableForeignKeys   []string `json:"table_foreign_keys"`
	TableCompatibleDDL []string `json:"table_compatible_ddl"`
}

func IReverse

func IReverse(s reverse.Generator) (*DDL, error)

func (*DDL) GenDDLStructure added in v1.0.13

func (d *DDL) GenDDLStructure() ([]string, []string)

func (*DDL) String added in v1.0.8

func (d *DDL) String() string

func (*DDL) Write added in v1.0.10

func (d *DDL) Write(w *reverse.Write) (string, error)

func (*DDL) WriteDB added in v1.0.13

func (d *DDL) WriteDB(w *reverse.Write) (string, error)

func (*DDL) WriteFile added in v1.0.13

func (d *DDL) WriteFile(w *reverse.Write) (string, error)

type Info added in v1.0.8

type Info struct {
	SourceTableDDL    string              `json:"-"` // 忽略
	PrimaryKeyINFO    []map[string]string `json:"primary_key_info"`
	UniqueKeyINFO     []map[string]string `json:"unique_key_info"`
	ForeignKeyINFO    []map[string]string `json:"foreign_key_info"`
	CheckKeyINFO      []map[string]string `json:"check_key_info"`
	UniqueIndexINFO   []map[string]string `json:"unique_index_info"`
	NormalIndexINFO   []map[string]string `json:"normal_index_info"`
	TableCommentINFO  []map[string]string `json:"table_comment_info"`
	TableColumnINFO   []map[string]string `json:"table_column_info"`
	ColumnCommentINFO []map[string]string `json:"column_comment_info"`
}

type Reverse added in v1.0.8

type Reverse struct {
	Ctx    context.Context
	Cfg    *config.Config
	Mysql  *mysql.MySQL
	Oracle *oracle.Oracle
	MetaDB *meta.Meta
}

func NewReverse added in v1.0.10

func NewReverse(ctx context.Context, cfg *config.Config) (*Reverse, error)

func (*Reverse) Reverse added in v1.0.10

func (r *Reverse) Reverse() error

type Rule

type Rule struct {
	*Table
	*Info
}

func IReader

func IReader(r reverse.Reader) (*Rule, error)

func (*Rule) GenCreateTableDDL

func (r *Rule) GenCreateTableDDL() (interface{}, error)

func (*Rule) GenSchemaName added in v1.0.8

func (r *Rule) GenSchemaName() string

func (*Rule) GenTableCheckKey

func (r *Rule) GenTableCheckKey() (checkKeys []string, err error)

func (*Rule) GenTableColumn

func (r *Rule) GenTableColumn() (tableColumns []string, err error)

func (*Rule) GenTableColumnComment

func (r *Rule) GenTableColumnComment() (columnComments []string, err error)

func (*Rule) GenTableComment

func (r *Rule) GenTableComment() (tableComment string, err error)

func (*Rule) GenTableForeignKey

func (r *Rule) GenTableForeignKey() (foreignKeys []string, err error)

func (*Rule) GenTableKeys added in v1.0.8

func (r *Rule) GenTableKeys() (tableKeys []string, compatibilityIndexSQL []string, err error)

func (*Rule) GenTableName added in v1.0.8

func (r *Rule) GenTableName() string

func (*Rule) GenTableNormalIndex

func (r *Rule) GenTableNormalIndex() (normalIndexes []string, compatibilityIndexSQL []string, err error)

func (*Rule) GenTablePrefix

func (r *Rule) GenTablePrefix() (string, string)

func (*Rule) GenTablePrimaryKey

func (r *Rule) GenTablePrimaryKey() (primaryKeys []string, err error)

func (*Rule) GenTableSuffix added in v1.0.8

func (r *Rule) GenTableSuffix() (string, error)

O2M Special

func (*Rule) GenTableUniqueIndex

func (r *Rule) GenTableUniqueIndex() (uniqueIndexes []string, compatibilityIndexSQL []string, err error)

func (*Rule) GenTableUniqueKey

func (r *Rule) GenTableUniqueKey() (uniqueKeys []string, err error)

func (*Rule) String

func (r *Rule) String() string

type Table

type Table struct {
	Ctx                   context.Context `json:"-"`
	SourceSchemaName      string          `json:"source_schema_name"`
	TargetSchemaName      string          `json:"target_schema_name"`
	SourceTableName       string          `json:"source_table_name"`
	TargetDBType          string          `json:"target_db_type"`
	TargetDBVersion       string          `json:"target_db_version"`
	TargetTableName       string          `json:"target_table_name"`
	TargetTableOption     string          `json:"target_table_option"`
	OracleCollation       bool            `json:"oracle_collation"`
	SourceSchemaCollation string          `json:"source_schema_collation"` // 可为空
	SourceTableCollation  string          `json:"source_table_collation"`  // 可为空
	SourceDBNLSSort       string          `json:"sourcedb_nlssort"`
	SourceDBNLSComp       string          `json:"sourcedb_nlscomp"`
	SourceTableType       string          `json:"source_table_type"`

	TableColumnDatatypeRule   map[string]string `json:"table_column_datatype_rule"`
	TableColumnDefaultValRule map[string]string `json:"table_column_default_val_rule"`
	Overwrite                 bool              `json:"overwrite"`
	Oracle                    *oracle.Oracle    `json:"-"`
	MySQL                     *mysql.MySQL      `json:"-"`
	MetaDB                    *meta.Meta        `json:"-"`
}

func GenReverseTableTask

func GenReverseTableTask(r *Reverse, tableNameRule map[string]string, tableColumnRule, tableDefaultRule map[string]map[string]string, oracleDBVersion string, oracleCollation bool, exporters []string, nlsSort, nlsComp string) ([]*Table, error)

func (*Table) GetTableCheckKey

func (t *Table) GetTableCheckKey() ([]map[string]string, error)

func (*Table) GetTableColumnComment

func (t *Table) GetTableColumnComment() ([]map[string]string, error)

func (*Table) GetTableColumnMeta

func (t *Table) GetTableColumnMeta() ([]map[string]string, error)

func (*Table) GetTableComment

func (t *Table) GetTableComment() ([]map[string]string, error)

func (*Table) GetTableForeignKey

func (t *Table) GetTableForeignKey() ([]map[string]string, error)

func (*Table) GetTableInfo added in v1.0.8

func (t *Table) GetTableInfo() (interface{}, error)

func (*Table) GetTableNormalIndex

func (t *Table) GetTableNormalIndex() ([]map[string]string, error)

func (*Table) GetTableOriginDDL added in v1.0.13

func (t *Table) GetTableOriginDDL() (string, error)

func (*Table) GetTablePrimaryKey

func (t *Table) GetTablePrimaryKey() ([]map[string]string, error)

func (*Table) GetTableUniqueIndex

func (t *Table) GetTableUniqueIndex() ([]map[string]string, error)

func (*Table) GetTableUniqueKey

func (t *Table) GetTableUniqueKey() ([]map[string]string, error)

func (*Table) String

func (t *Table) String() string

Jump to

Keyboard shortcuts

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