internal

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MySQLFieldType

func MySQLFieldType(sqlType string) (f string)

func PostgresFieldType

func PostgresFieldType(sqlType string) (f string)

Types

type ConvertOption

type ConvertOption func(*ConvertOptions)

ConvertOption allows for managing import configuration using functional options.

func WithDriver

func WithDriver(drv *schemasource.Driver) ConvertOption

WithDriver provides an import driver to be used by SchemaConverter.

func WithExcludedTables

func WithExcludedTables(tables []string) ConvertOption

WithExcludedTables supplies the set of includedTables to exclude.

func WithIncludedTables

func WithIncludedTables(tables []string) ConvertOption

WithIncludedTables limits the schema import to a set of given includedTables (by all includedTables are imported)

func WithModuleName

func WithModuleName(name string) ConvertOption

func WithModuleVersion

func WithModuleVersion(ver string) ConvertOption

func WithProtoPath

func WithProtoPath(path string) ConvertOption

WithProtoPath provides a path for writing the generated protocol buffer definitions.

func WithSchemaPath

func WithSchemaPath(path string) ConvertOption

func WithServiceType

func WithServiceType(serviceType string) ConvertOption

func WithSourceModuleName

func WithSourceModuleName(name string) ConvertOption

type ConvertOptions

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

ConvertOptions are the options passed on to every SchemaConverter.

type FieldData

type FieldData struct {
	Name         string // 字段名
	Type         string // 字段类型(Proto类型)
	SqlType      string // 原始SQL类型
	Null         bool   // 是否允许为 NULL
	Comment      string // 字段注释
	IsPrimaryKey bool   // 是否为主键
}

FieldData 字段数据

type Options

type Options struct {
	Driver string `json:"driver"` // Driver name, e.g., "mysql", "postgres"
	Source string `json:"source"` // Data source name (DSN), e.g., "mysql://user:pass@tcp(localhost:3306)/dbname"

	IncludedTables []string `json:"included_tables"` // IncludedTables to inspect (all if empty)
	ExcludedTables []string `json:"excluded_tables"` // ExcludedTables to exclude from inspection

	OutputPath string `json:"output_path"` // Path to save the generated code

	SourceModule string `json:"sourceModule"` // Source module name, for REST service generate, e.g., "admin"
	Module       string `json:"module"`       // Module name for the generated code, e.g., "admin"
	Version      string `json:"version"`      // Version of the module, e.g., "v1"
	Service      string `json:"service"`      // generate service code, "rest" for REST service, "grpc" for gRPC service
}

type SchemaConverter

type SchemaConverter interface {
	SchemaTables(context.Context) ([]*TableData, error)
}

func NewConvert

func NewConvert(opts ...ConvertOption) (SchemaConverter, error)

func NewGoSchema added in v1.0.4

func NewGoSchema(i *ConvertOptions) (SchemaConverter, error)

NewGoSchema 返回 Go 源码数据源(ent:// 与 gorm://)的转换器: schemasource 的内存 Inspector 已把 ent schema / gorm model 目录还原为 atlas 表,类型文本为 MySQL 风格,先 MySQL 后 PostgreSQL 回退。

func NewText

func NewText(i *ConvertOptions) (SchemaConverter, error)

NewText 返回 DDL 文本驱动 sink 的转换器。

type TableData

type TableData struct {
	Name      string      // 表名
	Comment   string      // 表注释
	Charset   string      // 字符集
	Collation string      // 排序规则
	Fields    []FieldData // 字段数据
}

TableData 表数据

func (TableData) WithComment

func (t TableData) WithComment() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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