internal

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 14 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 *mux.ConvertDriver) 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 added in v0.0.10

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 // 字段类型
	Null    bool   // 是否允许为 NULL
	Comment string // 字段注释
}

FieldData 字段数据

type MySQL

type MySQL struct {
	*ConvertOptions
}

MySQL holds the schema import options and an Atlas inspector instance

func NewMySQL

func NewMySQL(i *ConvertOptions) (*MySQL, error)

NewMySQL - create aמ import structure for MySQL.

func (*MySQL) SchemaTables

func (m *MySQL) SchemaTables(ctx context.Context) ([]*TableData, error)

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 Postgres

type Postgres struct {
	*ConvertOptions
}

Postgres implements SchemaConverter for PostgreSQL databases.

func (*Postgres) SchemaTables

func (p *Postgres) SchemaTables(ctx context.Context) ([]*TableData, error)

type SchemaConverter

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

func NewConvert

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

func NewPostgreSQL

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

NewPostgreSQL - returns a new *Postgres.

type TableData

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

TableData 表数据

func (TableData) WithComment

func (t TableData) WithComment() bool

type Text added in v0.0.10

type Text struct {
	*ConvertOptions
}

func NewText added in v0.0.10

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

func (*Text) InspectSchema added in v0.0.10

func (t *Text) InspectSchema(sqlText string, s *schema.Schema) (*schema.Schema, error)

func (*Text) ParseType added in v0.0.10

func (t *Text) ParseType(raw string) (schema.Type, error)

func (*Text) SchemaTables added in v0.0.10

func (t *Text) SchemaTables(ctx context.Context) ([]*TableData, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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