Documentation ¶
Index ¶
- Constants
- Variables
- type AddColumnMigration
- type AddIndexMigration
- type AddTableMigration
- type BaseDialect
- func (db *BaseDialect) AddColumnSql(tableName string, col *Column) string
- func (b *BaseDialect) AndStr() string
- func (db *BaseDialect) CopyTableData(sourceTable string, targetTable string, sourceCols []string, ...) string
- func (db *BaseDialect) CreateIndexSql(tableName string, index *Index) string
- func (b *BaseDialect) CreateTableSql(table *Table) string
- func (b *BaseDialect) Default(col *Column) string
- func (d *BaseDialect) DriverName() string
- func (db *BaseDialect) DropIndexSql(tableName string, index *Index) string
- func (db *BaseDialect) DropTable(tableName string) string
- func (b *BaseDialect) EqStr() string
- func (b *BaseDialect) LikeStr() string
- func (b *BaseDialect) OrStr() string
- func (db *BaseDialect) QuoteColList(cols []string) string
- func (db *BaseDialect) RenameTable(oldName string, newName string) string
- func (b *BaseDialect) ShowCreateNull() bool
- func (db *BaseDialect) UpdateTableSql(tableName string, columns []*Column) string
- type CodeMigration
- type Column
- type ColumnType
- type CopyTableDataMigration
- type Dialect
- type DropIndexMigration
- type DropTableMigration
- type IfTableExistsCondition
- type Index
- type Migration
- type MigrationBase
- type MigrationCondition
- type MigrationLog
- type Migrator
- type Mysql
- func (db *Mysql) AutoIncrStr() string
- func (db *Mysql) BooleanStr(value bool) string
- func (db *Mysql) Quote(name string) string
- func (db *Mysql) QuoteStr() string
- func (db *Mysql) SqlType(c *Column) string
- func (db *Mysql) SupportEngine() bool
- func (db *Mysql) TableCheckSql(tableName string) (string, []interface{})
- func (db *Mysql) UpdateTableSql(tableName string, columns []*Column) string
- type Postgres
- func (db *Postgres) AutoIncrStr() string
- func (db *Postgres) BooleanStr(value bool) string
- func (b *Postgres) Default(col *Column) string
- func (db *Postgres) DropIndexSql(tableName string, index *Index) string
- func (b *Postgres) LikeStr() string
- func (db *Postgres) Quote(name string) string
- func (db *Postgres) QuoteStr() string
- func (db *Postgres) SqlType(c *Column) string
- func (db *Postgres) SupportEngine() bool
- func (db *Postgres) TableCheckSql(tableName string) (string, []interface{})
- func (db *Postgres) UpdateTableSql(tableName string, columns []*Column) string
- type RawSqlMigration
- type RenameTableMigration
- type SQLType
- type Sqlite3
- func (db *Sqlite3) AutoIncrStr() string
- func (db *Sqlite3) BooleanStr(value bool) string
- func (db *Sqlite3) DropIndexSql(tableName string, index *Index) string
- func (db *Sqlite3) Quote(name string) string
- func (db *Sqlite3) QuoteStr() string
- func (db *Sqlite3) SqlType(c *Column) string
- func (db *Sqlite3) SupportEngine() bool
- func (db *Sqlite3) TableCheckSql(tableName string) (string, []interface{})
- type Table
- type TableCharsetMigration
Constants ¶
View Source
const ( POSTGRES = "postgres" SQLITE = "sqlite3" MYSQL = "mysql" )
View Source
const ( IndexType = iota + 1 UniqueIndex )
Variables ¶
View Source
var ( DB_Bit = "BIT" DB_TinyInt = "TINYINT" DB_SmallInt = "SMALLINT" DB_MediumInt = "MEDIUMINT" DB_Int = "INT" DB_Integer = "INTEGER" DB_BigInt = "BIGINT" DB_Enum = "ENUM" DB_Set = "SET" DB_Char = "CHAR" DB_Varchar = "VARCHAR" DB_NVarchar = "NVARCHAR" DB_TinyText = "TINYTEXT" DB_Text = "TEXT" DB_MediumText = "MEDIUMTEXT" DB_LongText = "LONGTEXT" DB_Uuid = "UUID" DB_Date = "DATE" DB_DateTime = "DATETIME" DB_Time = "TIME" DB_TimeStamp = "TIMESTAMP" DB_TimeStampz = "TIMESTAMPZ" DB_Decimal = "DECIMAL" DB_Numeric = "NUMERIC" DB_Real = "REAL" DB_Float = "FLOAT" DB_Double = "DOUBLE" DB_Binary = "BINARY" DB_VarBinary = "VARBINARY" DB_TinyBlob = "TINYBLOB" DB_Blob = "BLOB" DB_MediumBlob = "MEDIUMBLOB" DB_LongBlob = "LONGBLOB" DB_Bytea = "BYTEA" DB_Bool = "BOOL" DB_Serial = "SERIAL" DB_BigSerial = "BIGSERIAL" )
Functions ¶
This section is empty.
Types ¶
type AddColumnMigration ¶
type AddColumnMigration struct { MigrationBase // contains filtered or unexported fields }
func NewAddColumnMigration ¶
func NewAddColumnMigration(table Table, col *Column) *AddColumnMigration
func (*AddColumnMigration) Column ¶
func (m *AddColumnMigration) Column(col *Column) *AddColumnMigration
func (*AddColumnMigration) Sql ¶
func (m *AddColumnMigration) Sql(dialect Dialect) string
func (*AddColumnMigration) Table ¶
func (m *AddColumnMigration) Table(tableName string) *AddColumnMigration
type AddIndexMigration ¶
type AddIndexMigration struct { MigrationBase // contains filtered or unexported fields }
func NewAddIndexMigration ¶
func NewAddIndexMigration(table Table, index *Index) *AddIndexMigration
func (*AddIndexMigration) Sql ¶
func (m *AddIndexMigration) Sql(dialect Dialect) string
func (*AddIndexMigration) Table ¶
func (m *AddIndexMigration) Table(tableName string) *AddIndexMigration
type AddTableMigration ¶
type AddTableMigration struct { MigrationBase // contains filtered or unexported fields }
func NewAddTableMigration ¶
func NewAddTableMigration(table Table) *AddTableMigration
func (*AddTableMigration) Sql ¶
func (m *AddTableMigration) Sql(d Dialect) string
type BaseDialect ¶
type BaseDialect struct {
// contains filtered or unexported fields
}
func (*BaseDialect) AddColumnSql ¶
func (db *BaseDialect) AddColumnSql(tableName string, col *Column) string
func (*BaseDialect) AndStr ¶
func (b *BaseDialect) AndStr() string
func (*BaseDialect) CopyTableData ¶
func (*BaseDialect) CreateIndexSql ¶
func (db *BaseDialect) CreateIndexSql(tableName string, index *Index) string
func (*BaseDialect) CreateTableSql ¶
func (b *BaseDialect) CreateTableSql(table *Table) string
func (*BaseDialect) Default ¶
func (b *BaseDialect) Default(col *Column) string
func (*BaseDialect) DriverName ¶
func (d *BaseDialect) DriverName() string
func (*BaseDialect) DropIndexSql ¶
func (db *BaseDialect) DropIndexSql(tableName string, index *Index) string
func (*BaseDialect) DropTable ¶
func (db *BaseDialect) DropTable(tableName string) string
func (*BaseDialect) EqStr ¶
func (b *BaseDialect) EqStr() string
func (*BaseDialect) LikeStr ¶
func (b *BaseDialect) LikeStr() string
func (*BaseDialect) OrStr ¶
func (b *BaseDialect) OrStr() string
func (*BaseDialect) QuoteColList ¶
func (db *BaseDialect) QuoteColList(cols []string) string
func (*BaseDialect) RenameTable ¶
func (db *BaseDialect) RenameTable(oldName string, newName string) string
func (*BaseDialect) ShowCreateNull ¶
func (b *BaseDialect) ShowCreateNull() bool
func (*BaseDialect) UpdateTableSql ¶ added in v4.3.0
func (db *BaseDialect) UpdateTableSql(tableName string, columns []*Column) string
type CodeMigration ¶ added in v4.6.4
type Column ¶
type Column struct { Name string Type string Length int Length2 int Nullable bool IsPrimaryKey bool IsAutoIncrement bool Default string }
func (*Column) StringNoPk ¶
type CopyTableDataMigration ¶
type CopyTableDataMigration struct { MigrationBase // contains filtered or unexported fields }
func NewCopyTableDataMigration ¶
func NewCopyTableDataMigration(targetTable string, sourceTable string, colMap map[string]string) *CopyTableDataMigration
func (*CopyTableDataMigration) IfTableExists ¶
func (m *CopyTableDataMigration) IfTableExists(tableName string) *CopyTableDataMigration
func (*CopyTableDataMigration) Sql ¶
func (m *CopyTableDataMigration) Sql(d Dialect) string
type Dialect ¶
type Dialect interface { DriverName() string QuoteStr() string Quote(string) string AndStr() string AutoIncrStr() string OrStr() string EqStr() string ShowCreateNull() bool SqlType(col *Column) string SupportEngine() bool LikeStr() string Default(col *Column) string BooleanStr(bool) string CreateIndexSql(tableName string, index *Index) string CreateTableSql(table *Table) string AddColumnSql(tableName string, col *Column) string CopyTableData(sourceTable string, targetTable string, sourceCols []string, targetCols []string) string DropTable(tableName string) string DropIndexSql(tableName string, index *Index) string TableCheckSql(tableName string) (string, []interface{}) RenameTable(oldName string, newName string) string UpdateTableSql(tableName string, columns []*Column) string }
func NewDialect ¶
type DropIndexMigration ¶
type DropIndexMigration struct { MigrationBase // contains filtered or unexported fields }
func NewDropIndexMigration ¶
func NewDropIndexMigration(table Table, index *Index) *DropIndexMigration
func (*DropIndexMigration) Sql ¶
func (m *DropIndexMigration) Sql(dialect Dialect) string
type DropTableMigration ¶
type DropTableMigration struct { MigrationBase // contains filtered or unexported fields }
func NewDropTableMigration ¶
func NewDropTableMigration(tableName string) *DropTableMigration
func (*DropTableMigration) Sql ¶
func (m *DropTableMigration) Sql(d Dialect) string
type IfTableExistsCondition ¶
type IfTableExistsCondition struct {
TableName string
}
func (*IfTableExistsCondition) Sql ¶
func (c *IfTableExistsCondition) Sql(dialect Dialect) (string, []interface{})
type Migration ¶
type Migration interface { Sql(dialect Dialect) string Id() string SetId(string) GetCondition() MigrationCondition }
type MigrationBase ¶
type MigrationBase struct { Condition MigrationCondition // contains filtered or unexported fields }
func (*MigrationBase) GetCondition ¶
func (m *MigrationBase) GetCondition() MigrationCondition
func (*MigrationBase) Id ¶
func (m *MigrationBase) Id() string
func (*MigrationBase) SetId ¶
func (m *MigrationBase) SetId(id string)
type MigrationCondition ¶
type MigrationLog ¶
type Migrator ¶
type Migrator struct { Dialect Dialect Logger log.Logger // contains filtered or unexported fields }
func NewMigrator ¶
func (*Migrator) AddMigration ¶
func (*Migrator) GetMigrationLog ¶
func (mg *Migrator) GetMigrationLog() (map[string]MigrationLog, error)
type Mysql ¶
type Mysql struct {
BaseDialect
}
func NewMysqlDialect ¶
func NewMysqlDialect() *Mysql
func (*Mysql) AutoIncrStr ¶
func (*Mysql) BooleanStr ¶
func (*Mysql) SupportEngine ¶
func (*Mysql) TableCheckSql ¶
type Postgres ¶
type Postgres struct {
BaseDialect
}
func NewPostgresDialect ¶
func NewPostgresDialect() *Postgres
func (*Postgres) AutoIncrStr ¶
func (*Postgres) BooleanStr ¶
func (*Postgres) DropIndexSql ¶
func (*Postgres) SupportEngine ¶
func (*Postgres) TableCheckSql ¶
type RawSqlMigration ¶
type RawSqlMigration struct { MigrationBase // contains filtered or unexported fields }
func (*RawSqlMigration) Mysql ¶
func (m *RawSqlMigration) Mysql(sql string) *RawSqlMigration
func (*RawSqlMigration) Postgres ¶
func (m *RawSqlMigration) Postgres(sql string) *RawSqlMigration
func (*RawSqlMigration) Sql ¶
func (m *RawSqlMigration) Sql(dialect Dialect) string
func (*RawSqlMigration) Sqlite ¶
func (m *RawSqlMigration) Sqlite(sql string) *RawSqlMigration
type RenameTableMigration ¶
type RenameTableMigration struct { MigrationBase // contains filtered or unexported fields }
func NewRenameTableMigration ¶
func NewRenameTableMigration(oldName string, newName string) *RenameTableMigration
func (*RenameTableMigration) IfTableExists ¶
func (m *RenameTableMigration) IfTableExists(tableName string) *RenameTableMigration
func (*RenameTableMigration) Rename ¶
func (m *RenameTableMigration) Rename(oldName string, newName string) *RenameTableMigration
func (*RenameTableMigration) Sql ¶
func (m *RenameTableMigration) Sql(d Dialect) string
type Sqlite3 ¶
type Sqlite3 struct {
BaseDialect
}
func NewSqlite3Dialect ¶
func NewSqlite3Dialect() *Sqlite3
func (*Sqlite3) AutoIncrStr ¶
func (*Sqlite3) BooleanStr ¶
func (*Sqlite3) DropIndexSql ¶
func (*Sqlite3) SupportEngine ¶
func (*Sqlite3) TableCheckSql ¶
type TableCharsetMigration ¶ added in v4.3.0
type TableCharsetMigration struct { MigrationBase // contains filtered or unexported fields }
func NewTableCharsetMigration ¶ added in v4.3.0
func NewTableCharsetMigration(tableName string, columns []*Column) *TableCharsetMigration
func (*TableCharsetMigration) Sql ¶ added in v4.3.0
func (m *TableCharsetMigration) Sql(d Dialect) string
Click to show internal directories.
Click to hide internal directories.