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) CleanDB() error
- func (db *BaseDialect) ColString(col *Column) string
- func (db *BaseDialect) ColStringNoPk(col *Column) 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 (db *BaseDialect) DateTimeFunc(value string) 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 (db *BaseDialect) Limit(limit int64) string
- func (db *BaseDialect) LimitOffset(limit int64, offset int64) string
- func (db *BaseDialect) NoOpSql() string
- func (b *BaseDialect) OrStr() string
- func (db *BaseDialect) PostInsertId(table string, sess *xorm.Session) error
- func (db *BaseDialect) PreInsertId(table string, sess *xorm.Session) error
- 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) CleanDB() error
- func (db *Mysql) IsUniqueConstraintViolation(err error) bool
- func (db *Mysql) Quote(name string) 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 (db *Postgres) CleanDB() error
- func (b *Postgres) Default(col *Column) string
- func (db *Postgres) DropIndexSql(tableName string, index *Index) string
- func (db *Postgres) IsUniqueConstraintViolation(err error) bool
- func (b *Postgres) LikeStr() string
- func (db *Postgres) Quote(name string) 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
- func (m *RawSqlMigration) Default(sql string) *RawSqlMigration
- func (m *RawSqlMigration) Mssql(sql string) *RawSqlMigration
- func (m *RawSqlMigration) Mysql(sql string) *RawSqlMigration
- func (m *RawSqlMigration) Postgres(sql string) *RawSqlMigration
- func (m *RawSqlMigration) Set(dialect string, sql string) *RawSqlMigration
- func (m *RawSqlMigration) Sql(dialect Dialect) string
- func (m *RawSqlMigration) Sqlite(sql string) *RawSqlMigration
- type RenameTableMigration
- type SQLType
- type Sqlite3
- func (db *Sqlite3) AutoIncrStr() string
- func (db *Sqlite3) BooleanStr(value bool) string
- func (db *Sqlite3) CleanDB() error
- func (db *Sqlite3) DateTimeFunc(value string) string
- func (db *Sqlite3) DropIndexSql(tableName string, index *Index) string
- func (db *Sqlite3) IsUniqueConstraintViolation(err error) bool
- func (db *Sqlite3) Quote(name string) 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" MSSQL = "mssql" )
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) CleanDB ¶
func (db *BaseDialect) CleanDB() error
func (*BaseDialect) ColString ¶
func (db *BaseDialect) ColString(col *Column) string
func (*BaseDialect) ColStringNoPk ¶
func (db *BaseDialect) ColStringNoPk(col *Column) 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) DateTimeFunc ¶
func (db *BaseDialect) DateTimeFunc(value string) 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) Limit ¶
func (db *BaseDialect) Limit(limit int64) string
func (*BaseDialect) LimitOffset ¶
func (db *BaseDialect) LimitOffset(limit int64, offset int64) string
func (*BaseDialect) NoOpSql ¶
func (db *BaseDialect) NoOpSql() string
func (*BaseDialect) OrStr ¶
func (b *BaseDialect) OrStr() string
func (*BaseDialect) PostInsertId ¶
func (db *BaseDialect) PostInsertId(table string, sess *xorm.Session) error
func (*BaseDialect) PreInsertId ¶
func (db *BaseDialect) PreInsertId(table string, sess *xorm.Session) error
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 ¶
func (db *BaseDialect) UpdateTableSql(tableName string, columns []*Column) string
type CodeMigration ¶
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 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 DateTimeFunc(string) 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 ColString(*Column) string ColStringNoPk(*Column) string Limit(limit int64) string LimitOffset(limit int64, offset int64) string PreInsertId(table string, sess *xorm.Session) error PostInsertId(table string, sess *xorm.Session) error CleanDB() error NoOpSql() string IsUniqueConstraintViolation(err error) bool }
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)
func (*Migrator) MigrationsCount ¶
type Mysql ¶
type Mysql struct {
BaseDialect
}
func NewMysqlDialect ¶
func (*Mysql) AutoIncrStr ¶
func (*Mysql) BooleanStr ¶
func (*Mysql) IsUniqueConstraintViolation ¶
func (*Mysql) SupportEngine ¶
func (*Mysql) TableCheckSql ¶
type Postgres ¶
type Postgres struct {
BaseDialect
}
func NewPostgresDialect ¶
func (*Postgres) AutoIncrStr ¶
func (*Postgres) BooleanStr ¶
func (*Postgres) DropIndexSql ¶
func (*Postgres) IsUniqueConstraintViolation ¶
func (*Postgres) SupportEngine ¶
func (*Postgres) TableCheckSql ¶
type RawSqlMigration ¶
type RawSqlMigration struct { MigrationBase // contains filtered or unexported fields }
func NewRawSqlMigration ¶
func NewRawSqlMigration(sql string) *RawSqlMigration
func (*RawSqlMigration) Default ¶
func (m *RawSqlMigration) Default(sql string) *RawSqlMigration
func (*RawSqlMigration) Mssql ¶
func (m *RawSqlMigration) Mssql(sql string) *RawSqlMigration
func (*RawSqlMigration) Mysql ¶
func (m *RawSqlMigration) Mysql(sql string) *RawSqlMigration
func (*RawSqlMigration) Postgres ¶
func (m *RawSqlMigration) Postgres(sql string) *RawSqlMigration
func (*RawSqlMigration) Set ¶
func (m *RawSqlMigration) Set(dialect string, 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 (*Sqlite3) AutoIncrStr ¶
func (*Sqlite3) BooleanStr ¶
func (*Sqlite3) DateTimeFunc ¶
func (*Sqlite3) DropIndexSql ¶
func (*Sqlite3) IsUniqueConstraintViolation ¶
func (*Sqlite3) SupportEngine ¶
func (*Sqlite3) TableCheckSql ¶
type TableCharsetMigration ¶
type TableCharsetMigration struct { MigrationBase // contains filtered or unexported fields }
func NewTableCharsetMigration ¶
func NewTableCharsetMigration(tableName string, columns []*Column) *TableCharsetMigration
func (*TableCharsetMigration) Sql ¶
func (m *TableCharsetMigration) Sql(d Dialect) string
Click to show internal directories.
Click to hide internal directories.