migrate

package
v1.0.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:   "migrate",
	Usage:  "根据数据库表生成模板代码,模板可以自定义",
	Flags:  flags,
	Action: action,
}

Functions

This section is empty.

Types

type Column

type Column struct {
	TableName    string
	Name         string
	SQLType      string
	Comment      string
	IsPrimaryKey bool
	DefaultValue string
	Extra        string
}

type Config

type Config struct {
	DS     *DS            `yaml:"ds"`
	Target *ReverseTarget `yaml:"target"`
}

Config config file

type Custom

type Custom struct {
	OutDir      string `yaml:"out-dir"`      // 必须,生成文件路径
	TemplateDir string `yaml:"template-dir"` // 可选,模板路径
	TagName     string `yaml:"tag-name"`     // 可选,生成 model 的 tag,默认 json
	UseAdmin    bool   `yaml:"use-admin"`    // 可选,是否生成管理后台接口和页面,对所有表生效
	Gomod       string `yaml:"gomod"`        // 必须,项目 go mod module 配置
	Var         Var    `yaml:"exy"`          // 自定义变量,对所有表生效
}

type DS

type DS struct {
	Type string `yaml:"type"`
	Dsn  string `yaml:"dsn"`
}

type ReverseTarget

type ReverseTarget struct {
	Custom *Custom                `yaml:"custom"` // 自定义参数
	Tables map[string]TableConfig `yaml:"tables"` // 生成的数据库表名和对应的自定义变量
}

type Table

type Table struct {
	Name          string
	StructName    string
	Columns       []Column
	PrimaryKey    Column
	AutoIncrement bool
	Comment       string
	StoreEngine   string
	GoImports     []string
}

Table represents a database table

type TableConfig

type TableConfig struct {
	Module     string `yaml:"module"`
	SimpleName string `yaml:"simple-name"`
	IsTime     bool   `yaml:"is-time"`
	InputType  string `yaml:"input-type"`
	UseAdmin   *bool  `yaml:"use-admin"`
	Var        Var    `yaml:"var"`
}

type Var

type Var map[string]string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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