m2o

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 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 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 GenCompatibilityTable

func GenCompatibilityTable(f *reverse.File, sourceSchema string, errCompatibility map[string][]map[string]string, viewTables []string) error

func GenCreateSchema

func GenCreateSchema(f *reverse.File, sourceSchema, targetSchema string) error

func IWriter

func IWriter(f *reverse.File, w reverse.Writer) error

func MySQLTableColumnMapRule

func MySQLTableColumnMapRule(sourceSchema, sourceTable string, column o2m.Column) (string, string, error)

MySQL 表字段映射转换 -> Reverse 阶段

func PreCheckCompatibility

func PreCheckCompatibility(cfg *config.Config, mysql *mysql.MySQL, exporters []string, oracleDBVersion string, isExtended bool) ([]string, map[string][]map[string]string, map[string]string, map[string]string, error)

Types

type DDL

type DDL struct {
	SourceSchemaName string   `json:"source_schema"`
	SourceTableName  string   `json:"source_table_name"`
	IsPartition      bool     `json:"is_partition"`
	SourceTableType  string   `json:"source_table_type"`
	TargetSchemaName string   `json:"target_schema"`
	TargetTableName  string   `json:"target_table_name"`
	ReverseDDL       string   `json:"reverse_ddl"`
	ColumnCommentDDL []string `json:"column_comment_ddl"`
	TableComment     string   `json:"table_comment"`
	TableIndexDDL    []string `json:"table_index_ddl"`
	CheckKeyDDL      []string `json:"check_key_ddl"`
	ForeignKeyDDL    []string `json:"foreign_key_ddl"`
	CompatibleDDL    []string `json:"compatible_ddl"`
}

func IReverse

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

func (*DDL) Writer

func (d *DDL) Writer(f *reverse.File) error

type M2O

type M2O struct {
	// contains filtered or unexported fields
}

func NewM2OReverse

func NewM2OReverse(ctx context.Context, cfg *config.Config, mysql *mysql.MySQL, oracle *oracle.Oracle) *M2O

func (*M2O) NewReverse

func (m2o *M2O) NewReverse() error

type Rule

type Rule struct {
	Ctx               context.Context     `json:"-"`
	SourceSchema      string              `json:"source_schema"`
	SourceTableName   string              `json:"source_table_name"`
	TargetSchema      string              `json:"target_schema"`
	TargetTableName   string              `json:"target_table_name"`
	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"`
	IsPartition       bool                `json:"is_partition"`

	MySQL  *mysql.MySQL   `json:"-"`
	Oracle *oracle.Oracle `json:"-"`
}

func IReader

func IReader(ctx context.Context, mysql *mysql.MySQL, oracle *oracle.Oracle, t *Table, rd reverse.Reader) (*Rule, error)

func (*Rule) ChangeSchemaName

func (r *Rule) ChangeSchemaName() string

func (*Rule) ChangeTableColumnDefaultValue

func (r *Rule) ChangeTableColumnDefaultValue(dataDefault string) (string, error)

func (*Rule) ChangeTableColumnType

func (r *Rule) ChangeTableColumnType(sourceSchema, sourceTable, sourceColumn string, column interface{}) (string, error)

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

func (*Rule) ChangeTableName

func (r *Rule) ChangeTableName() string

func (*Rule) GenCreateTableDDL

func (r *Rule) GenCreateTableDDL() (reverseDDL string, checkKeyDDL []string, foreignKeyDDL []string, compatibleDDL []string, err error)

func (*Rule) GenTableCheckKey

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

func (*Rule) GenTableColumn

func (r *Rule) GenTableColumn() (columnMetas []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() (foreignKeyMetas []string, err error)

func (*Rule) GenTableKeyMeta

func (r *Rule) GenTableKeyMeta() (tableKeyMetas []string, compatibilityIndexSQL []string, err error)

func (*Rule) GenTableNormalIndex

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

func (*Rule) GenTablePrefix

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

func (*Rule) GenTablePrimaryKey

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

func (*Rule) GenTableUniqueIndex

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

func (*Rule) GenTableUniqueKey

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

func (*Rule) String

func (r *Rule) String() string

type Table

type Table struct {
	Ctx                     context.Context `json:"-"`
	MySQLDBType             string          `json:"my_sqldb_type"`
	OracleDBVersion         string          `json:"oracle_db_version"`
	OracleExtendedMode      bool            `json:"oracle_extended_mode"`
	SourceSchemaName        string          `json:"source_schema_name"`
	TargetSchemaName        string          `json:"target_schema_name"`
	SourceTableName         string          `json:"source_table_name"`
	IsPartition             bool            `json:"is_partition"`
	TargetTableName         string          `json:"target_table_name"`
	SourceTableCharacterSet string          `json:"source_table_character_set"`
	SourceTableCollation    string          `json:"source_table_collation"`
	Overwrite               bool            `json:"overwrite"`
	Oracle                  *oracle.Oracle  `json:"-"`
	MySQL                   *mysql.MySQL    `json:"-"`
}

func GenReverseTableTask

func GenReverseTableTask(cfg *config.Config, mysql *mysql.MySQL, oracle *oracle.Oracle, exporters []string, oracleDBVersion string, isExtended bool, tableCharSetMap map[string]string, tableCollationMap map[string]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) GetTableNormalIndex

func (t *Table) GetTableNormalIndex() ([]map[string]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