camConsole

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMigration

type BaseMigration struct {
	camStatics.MigrationInterface
	// contains filtered or unexported fields
}

base migration struct

func (*BaseMigration) AddColumn added in v0.5.0

func (m *BaseMigration) AddColumn(tableName, columnName string, columnI camStatics.MysqlColumnBuilderInterface)

Add column for table

func (*BaseMigration) AlterColumn added in v0.5.0

func (m *BaseMigration) AlterColumn(tableName, oldName, newName string, column camStatics.MysqlColumnBuilderInterface)

Alter table

func (*BaseMigration) Bigint added in v0.5.0

func (*BaseMigration) BigintPrimaryKey added in v0.5.0

Set bigint type primary key

func (*BaseMigration) Binary added in v0.5.0

func (*BaseMigration) Blob added in v0.5.0

func (*BaseMigration) Char added in v0.5.0

func (*BaseMigration) Column added in v0.5.0

Table column In order to keep table columns sort

func (*BaseMigration) CreateForeignKey added in v0.5.0

func (m *BaseMigration) CreateForeignKey(name, table string, columns []string, refTable string, refColumns []string)

Create foreign key

func (*BaseMigration) CreateIndex added in v0.5.0

func (m *BaseMigration) CreateIndex(indexName, tableName string, columnNames ...string)

Create index

func (*BaseMigration) CreateTable added in v0.5.0

func (m *BaseMigration) CreateTable(tableName string, columnList []camStatics.MysqlColumnBuilderInterface, options string)

Create table

Param options: a string after create table. Example: CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB COMMENT = 'table comment'

func (*BaseMigration) CreateUnique added in v0.5.0

func (m *BaseMigration) CreateUnique(indexName, tableName string, columnNames ...string)

Create unique

func (*BaseMigration) Datetime added in v0.5.0

func (*BaseMigration) Decimal added in v0.5.0

func (*BaseMigration) DefaultOption added in v0.5.0

func (m *BaseMigration) DefaultOption(comment string) string

func (*BaseMigration) Double added in v0.5.0

func (*BaseMigration) DropColumn added in v0.5.0

func (m *BaseMigration) DropColumn(tableName, columnName string)

Drop column

func (*BaseMigration) DropIndex added in v0.5.0

func (m *BaseMigration) DropIndex(tableName, indexName string)

Drop index

func (*BaseMigration) DropTable added in v0.5.0

func (m *BaseMigration) DropTable(tableName string)

Drop table

func (*BaseMigration) Exec

func (m *BaseMigration) Exec(sql string)

exec sql

func (*BaseMigration) Float added in v0.5.0

func (*BaseMigration) GetSqlList

func (m *BaseMigration) GetSqlList() []string

get sql list

func (*BaseMigration) Int added in v0.5.0

func (*BaseMigration) IntPrimaryKey added in v0.5.0

Set int type primary key

func (*BaseMigration) Longblob added in v0.5.0

func (*BaseMigration) Longtext added in v0.5.0

func (*BaseMigration) Mediumblob added in v0.5.0

func (*BaseMigration) Mediumint added in v0.5.0

func (*BaseMigration) Mediumtext added in v0.5.0

func (*BaseMigration) Option added in v0.5.0

func (m *BaseMigration) Option(comment, engine, charset, collate string) string

func (*BaseMigration) RenameColumn added in v0.5.0

func (m *BaseMigration) RenameColumn(tableName, oldName, newName string)

Rename column

func (*BaseMigration) RenameTable added in v0.5.0

func (m *BaseMigration) RenameTable(oldTableName, newTableName string)

Rename table

func (*BaseMigration) Smallint added in v0.5.0

func (*BaseMigration) Text added in v0.5.0

func (*BaseMigration) Timestamp added in v0.5.0

func (*BaseMigration) Tinyblob added in v0.5.0

func (*BaseMigration) Tinyint added in v0.5.0

func (*BaseMigration) Tinytext added in v0.5.0

func (*BaseMigration) Varbinary added in v0.5.0

func (*BaseMigration) Varchar added in v0.5.0

type ConsoleComponent

type ConsoleComponent struct {
	component.Component
	camRouter.RouterPlugin
	camContext.ContextPlugin
	// contains filtered or unexported fields
}

command component

func (*ConsoleComponent) GetMigrateUpVersionList

func (comp *ConsoleComponent) GetMigrateUpVersionList() []string

get migrate up version list.

func (*ConsoleComponent) Init

init

func (*ConsoleComponent) MigrateDown

func (comp *ConsoleComponent) MigrateDown()

down last database version

func (*ConsoleComponent) MigrateLastVersion

func (comp *ConsoleComponent) MigrateLastVersion() string

func (*ConsoleComponent) MigrateUp

func (comp *ConsoleComponent) MigrateUp()

up all database version

func (*ConsoleComponent) RunAction

func (comp *ConsoleComponent) RunAction()

run command Example:

# go build cam.go
# ./cam controllerName/actionName param1 param2

type ConsoleComponentConfig

type ConsoleComponentConfig struct {
	component.ComponentConfig
	camRouter.RouterPluginConfig
	camContext.ContextPluginConfig

	DatabaseDir     string // DatabaseComponentConfig file storage path. Default is: /[path to run dir]/database
	XormTemplateDir string // Deprecated: xorm template path.
	// contains filtered or unexported fields
}

console config

func NewConsoleComponentConfig

func NewConsoleComponentConfig() *ConsoleComponentConfig

new console config

func (*ConsoleComponentConfig) SetDatabaseDir

func (conf *ConsoleComponentConfig) SetDatabaseDir(dir string) *ConsoleComponentConfig

set migration's file dir

func (*ConsoleComponentConfig) SetGrpcOption added in v0.5.0

func (conf *ConsoleComponentConfig) SetGrpcOption(option *GrpcOption)

set grpc option

func (*ConsoleComponentConfig) SetXormTemplateDir

func (conf *ConsoleComponentConfig) SetXormTemplateDir(dir string) *ConsoleComponentConfig

set xorm dir

type ConsoleController

type ConsoleController struct {
	camRouter.Controller
}

func (*ConsoleController) GetArgv

func (ctrl *ConsoleController) GetArgv(key int) string

get params key start is 0 example:

/path/to/main.exe console/run argv0 argv1
controller.GetArgv(0) => "argv0"
controller.GetArgv(1) => "argv1"
controller.GetArgv(2) => ""
controller.GetArgv(-1) => ""

func (*ConsoleController) GetConsoleComponent

func (ctrl *ConsoleController) GetConsoleComponent() *ConsoleComponent

get console component

type GrpcController added in v0.5.0

type GrpcController struct {
	ConsoleController
}

func (*GrpcController) DownloadProtocGenGo added in v0.5.0

func (ctrl *GrpcController) DownloadProtocGenGo()

type GrpcOption added in v0.5.0

type GrpcOption struct {
	// the module's dirs
	//
	// Example: []string{"backend-grpc", "center-grpc"}
	GrpcDirs []string
}

type MigrateController

type MigrateController struct {
	ConsoleController
}

func (*MigrateController) Create

func (ctrl *MigrateController) Create()

create migration's file

func (*MigrateController) Down

func (ctrl *MigrateController) Down()

migrate down

func (*MigrateController) Generate added in v0.5.1

func (ctrl *MigrateController) Generate()

Gen xorm model's files

func (*MigrateController) Install added in v0.5.1

func (ctrl *MigrateController) Install()

Install xorm reverse command

func (*MigrateController) Sync added in v0.5.0

func (ctrl *MigrateController) Sync()

func (*MigrateController) Up

func (ctrl *MigrateController) Up()

migrate up

type Migration

type Migration struct {
	Version string    `xorm:"pk notnull"`
	DoneAt  time.Time `xorm:"timestamp created notnull"`
}

type MigrationTpl

type MigrationTpl struct {
	ClassName string
}

type XormController deprecated

type XormController struct {
	ConsoleController
}

Deprecated: remove on v0.6.0 xorm's console controller

func (*XormController) BeforeAction added in v0.4.3

func (ctrl *XormController) BeforeAction(action camStatics.ControllerActionInterface) bool

OVERWRITE

func (*XormController) Generate

func (ctrl *XormController) Generate()

Generate ORM classes automatically according to the database xorm reverse

usage: xorm reverse [-s] driverName datasourceName tmplPath [generatedPath] [tableFilterReg]

according database's tables and columns to generate codes for Go, C++ and etc.

-s                Generated one go file for every table
driverName        Database driver name, now supported four: mysql mymysql sqlite3 postgres
datasourceName    Database connection uri, for detail infomation please visit driver's project page
tmplPath          Template dir for generated. the default templates dir has provide 1 template
generatedPath     This parameter is optional, if blank, the default value is model, then will
generated all codes in model dir
tableFilterReg    Table name filter regexp

func (*XormController) InstallCmdXorm deprecated

func (ctrl *XormController) InstallCmdXorm()

Deprecated: remove on v0.6.0 install github.com/go-xorm/cmd/xorm

Jump to

Keyboard shortcuts

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