Documentation ¶
Index ¶
- Constants
- Variables
- type AddColumnMigration
- type AddIndexMigration
- type AddTableMigration
- type BaseDialect
- func (b *BaseDialect) AddColumnSQL(tableName string, col *Column) string
- func (b *BaseDialect) AndStr() string
- func (b *BaseDialect) CleanDB() error
- func (b *BaseDialect) ColString(col *Column) string
- func (b *BaseDialect) ColStringNoPk(col *Column) string
- func (b *BaseDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{})
- func (b *BaseDialect) CopyTableData(sourceTable string, targetTable string, sourceCols []string, ...) string
- func (b *BaseDialect) CreateIndexSQL(tableName string, index *Index) string
- func (b *BaseDialect) CreateTableSQL(table *Table) string
- func (b *BaseDialect) DateTimeFunc(value string) string
- func (b *BaseDialect) Default(col *Column) string
- func (b *BaseDialect) DriverName() string
- func (b *BaseDialect) DropIndexSQL(tableName string, index *Index) string
- func (b *BaseDialect) DropTable(tableName string) string
- func (b *BaseDialect) EqStr() string
- func (b *BaseDialect) LikeStr() string
- func (b *BaseDialect) Limit(limit int64) string
- func (b *BaseDialect) LimitOffset(limit int64, offset int64) string
- func (b *BaseDialect) NoOpSQL() string
- func (b *BaseDialect) OrStr() string
- func (b *BaseDialect) PostInsertId(table string, sess *xorm.Session) error
- func (b *BaseDialect) PreInsertId(table string, sess *xorm.Session) error
- func (b *BaseDialect) QuoteColList(cols []string) string
- func (b *BaseDialect) RenameTable(oldName string, newName string) string
- func (b *BaseDialect) ShowCreateNull() bool
- func (b *BaseDialect) TruncateDBTables() error
- func (b *BaseDialect) UpdateTableSQL(tableName string, columns []*Column) string
- func (b *BaseDialect) UpsertSQL(tableName string, keyCols, updateCols []string) string
- type CodeMigration
- type Column
- type ColumnType
- type CopyTableDataMigration
- type Dialect
- type DropIndexMigration
- type DropTableMigration
- type ExistsMigrationCondition
- type IfColumnNotExistsCondition
- type IfIndexExistsCondition
- type IfIndexNotExistsCondition
- type Index
- type Migration
- type MigrationBase
- type MigrationCondition
- type MigrationLog
- type Migrator
- type MySQLDialect
- func (db *MySQLDialect) AutoIncrStr() string
- func (db *MySQLDialect) BooleanStr(value bool) string
- func (db *MySQLDialect) CleanDB() error
- func (db *MySQLDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{})
- func (db *MySQLDialect) ErrorMessage(err error) string
- func (db *MySQLDialect) IndexCheckSQL(tableName, indexName string) (string, []interface{})
- func (db *MySQLDialect) IsDeadlock(err error) bool
- func (db *MySQLDialect) IsUniqueConstraintViolation(err error) bool
- func (db *MySQLDialect) Quote(name string) string
- func (db *MySQLDialect) SQLType(c *Column) string
- func (db *MySQLDialect) SupportEngine() bool
- func (db *MySQLDialect) TruncateDBTables() error
- func (db *MySQLDialect) UpdateTableSQL(tableName string, columns []*Column) string
- func (db *MySQLDialect) UpsertSQL(tableName string, keyCols, updateCols []string) string
- type NotExistsMigrationCondition
- type PostgresDialect
- func (db *PostgresDialect) AutoIncrStr() string
- func (db *PostgresDialect) BooleanStr(value bool) string
- func (db *PostgresDialect) CleanDB() error
- func (db *PostgresDialect) Default(col *Column) string
- func (db *PostgresDialect) DropIndexSQL(tableName string, index *Index) string
- func (db *PostgresDialect) ErrorMessage(err error) string
- func (db *PostgresDialect) IndexCheckSQL(tableName, indexName string) (string, []interface{})
- func (db *PostgresDialect) IsDeadlock(err error) bool
- func (db *PostgresDialect) IsUniqueConstraintViolation(err error) bool
- func (db *PostgresDialect) LikeStr() string
- func (db *PostgresDialect) PostInsertId(table string, sess *xorm.Session) error
- func (db *PostgresDialect) Quote(name string) string
- func (db *PostgresDialect) SQLType(c *Column) string
- func (db *PostgresDialect) SupportEngine() bool
- func (db *PostgresDialect) TruncateDBTables() error
- func (db *PostgresDialect) UpdateTableSQL(tableName string, columns []*Column) string
- func (db *PostgresDialect) UpsertSQL(tableName string, keyCols, updateCols []string) 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) SQL(dialect Dialect) string
- func (m *RawSQLMigration) SQLite(sql string) *RawSQLMigration
- func (m *RawSQLMigration) Set(dialect string, 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) ErrorMessage(err error) string
- func (db *SQLite3) IndexCheckSQL(tableName, indexName string) (string, []interface{})
- func (db *SQLite3) IsDeadlock(err error) bool
- 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) TruncateDBTables() error
- func (db *SQLite3) UpsertSQL(tableName string, keyCols, updateCols []string) string
- 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_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 (b *BaseDialect) AddColumnSQL(tableName string, col *Column) string
func (*BaseDialect) AndStr ¶
func (b *BaseDialect) AndStr() string
func (*BaseDialect) CleanDB ¶
func (b *BaseDialect) CleanDB() error
func (*BaseDialect) ColString ¶
func (b *BaseDialect) ColString(col *Column) string
func (*BaseDialect) ColStringNoPk ¶
func (b *BaseDialect) ColStringNoPk(col *Column) string
func (*BaseDialect) ColumnCheckSQL ¶
func (b *BaseDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{})
func (*BaseDialect) CopyTableData ¶
func (*BaseDialect) CreateIndexSQL ¶
func (b *BaseDialect) CreateIndexSQL(tableName string, index *Index) string
func (*BaseDialect) CreateTableSQL ¶
func (b *BaseDialect) CreateTableSQL(table *Table) string
func (*BaseDialect) DateTimeFunc ¶
func (b *BaseDialect) DateTimeFunc(value string) string
func (*BaseDialect) Default ¶
func (b *BaseDialect) Default(col *Column) string
func (*BaseDialect) DriverName ¶
func (b *BaseDialect) DriverName() string
func (*BaseDialect) DropIndexSQL ¶
func (b *BaseDialect) DropIndexSQL(tableName string, index *Index) string
func (*BaseDialect) DropTable ¶
func (b *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 (b *BaseDialect) Limit(limit int64) string
func (*BaseDialect) LimitOffset ¶
func (b *BaseDialect) LimitOffset(limit int64, offset int64) string
func (*BaseDialect) NoOpSQL ¶
func (b *BaseDialect) NoOpSQL() string
func (*BaseDialect) OrStr ¶
func (b *BaseDialect) OrStr() string
func (*BaseDialect) PostInsertId ¶
func (b *BaseDialect) PostInsertId(table string, sess *xorm.Session) error
func (*BaseDialect) PreInsertId ¶
func (b *BaseDialect) PreInsertId(table string, sess *xorm.Session) error
func (*BaseDialect) QuoteColList ¶
func (b *BaseDialect) QuoteColList(cols []string) string
func (*BaseDialect) RenameTable ¶
func (b *BaseDialect) RenameTable(oldName string, newName string) string
func (*BaseDialect) ShowCreateNull ¶
func (b *BaseDialect) ShowCreateNull() bool
func (*BaseDialect) TruncateDBTables ¶
func (b *BaseDialect) TruncateDBTables() error
func (*BaseDialect) UpdateTableSQL ¶
func (b *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) 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 RenameTable(oldName string, newName string) string UpdateTableSQL(tableName string, columns []*Column) string IndexCheckSQL(tableName, indexName string) (string, []interface{}) ColumnCheckSQL(tableName, columnName string) (string, []interface{}) // UpsertSQL returns the upsert sql statement for a dialect UpsertSQL(tableName string, keyCols, updateCols []string) 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 TruncateDBTables() error NoOpSQL() string IsUniqueConstraintViolation(err error) bool ErrorMessage(err error) string IsDeadlock(err error) bool }
func NewDialect ¶
func NewMysqlDialect ¶
func NewPostgresDialect ¶
func NewSQLite3Dialect ¶
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 ExistsMigrationCondition ¶
type ExistsMigrationCondition struct{}
func (*ExistsMigrationCondition) IsFulfilled ¶
func (c *ExistsMigrationCondition) IsFulfilled(results []map[string][]byte) bool
type IfColumnNotExistsCondition ¶
type IfColumnNotExistsCondition struct { NotExistsMigrationCondition TableName string ColumnName string }
func (*IfColumnNotExistsCondition) SQL ¶
func (c *IfColumnNotExistsCondition) SQL(dialect Dialect) (string, []interface{})
type IfIndexExistsCondition ¶
type IfIndexExistsCondition struct { ExistsMigrationCondition TableName string IndexName string }
func (*IfIndexExistsCondition) SQL ¶
func (c *IfIndexExistsCondition) SQL(dialect Dialect) (string, []interface{})
type IfIndexNotExistsCondition ¶
type IfIndexNotExistsCondition struct { NotExistsMigrationCondition TableName string IndexName string }
func (*IfIndexNotExistsCondition) SQL ¶
func (c *IfIndexNotExistsCondition) 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 MySQLDialect ¶
type MySQLDialect struct {
BaseDialect
}
func (*MySQLDialect) AutoIncrStr ¶
func (db *MySQLDialect) AutoIncrStr() string
func (*MySQLDialect) BooleanStr ¶
func (db *MySQLDialect) BooleanStr(value bool) string
func (*MySQLDialect) CleanDB ¶
func (db *MySQLDialect) CleanDB() error
func (*MySQLDialect) ColumnCheckSQL ¶
func (db *MySQLDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{})
func (*MySQLDialect) ErrorMessage ¶
func (db *MySQLDialect) ErrorMessage(err error) string
func (*MySQLDialect) IndexCheckSQL ¶
func (db *MySQLDialect) IndexCheckSQL(tableName, indexName string) (string, []interface{})
func (*MySQLDialect) IsDeadlock ¶
func (db *MySQLDialect) IsDeadlock(err error) bool
func (*MySQLDialect) IsUniqueConstraintViolation ¶
func (db *MySQLDialect) IsUniqueConstraintViolation(err error) bool
func (*MySQLDialect) Quote ¶
func (db *MySQLDialect) Quote(name string) string
func (*MySQLDialect) SQLType ¶
func (db *MySQLDialect) SQLType(c *Column) string
func (*MySQLDialect) SupportEngine ¶
func (db *MySQLDialect) SupportEngine() bool
func (*MySQLDialect) TruncateDBTables ¶
func (db *MySQLDialect) TruncateDBTables() error
TruncateDBTables truncates all the tables. A special case is the dashboard_acl table where we keep the default permissions.
func (*MySQLDialect) UpdateTableSQL ¶
func (db *MySQLDialect) UpdateTableSQL(tableName string, columns []*Column) string
type NotExistsMigrationCondition ¶
type NotExistsMigrationCondition struct{}
func (*NotExistsMigrationCondition) IsFulfilled ¶
func (c *NotExistsMigrationCondition) IsFulfilled(results []map[string][]byte) bool
type PostgresDialect ¶
type PostgresDialect struct {
BaseDialect
}
func (*PostgresDialect) AutoIncrStr ¶
func (db *PostgresDialect) AutoIncrStr() string
func (*PostgresDialect) BooleanStr ¶
func (db *PostgresDialect) BooleanStr(value bool) string
func (*PostgresDialect) CleanDB ¶
func (db *PostgresDialect) CleanDB() error
func (*PostgresDialect) Default ¶
func (db *PostgresDialect) Default(col *Column) string
func (*PostgresDialect) DropIndexSQL ¶
func (db *PostgresDialect) DropIndexSQL(tableName string, index *Index) string
func (*PostgresDialect) ErrorMessage ¶
func (db *PostgresDialect) ErrorMessage(err error) string
func (*PostgresDialect) IndexCheckSQL ¶
func (db *PostgresDialect) IndexCheckSQL(tableName, indexName string) (string, []interface{})
func (*PostgresDialect) IsDeadlock ¶
func (db *PostgresDialect) IsDeadlock(err error) bool
func (*PostgresDialect) IsUniqueConstraintViolation ¶
func (db *PostgresDialect) IsUniqueConstraintViolation(err error) bool
func (*PostgresDialect) LikeStr ¶
func (db *PostgresDialect) LikeStr() string
func (*PostgresDialect) PostInsertId ¶
func (db *PostgresDialect) PostInsertId(table string, sess *xorm.Session) error
func (*PostgresDialect) Quote ¶
func (db *PostgresDialect) Quote(name string) string
func (*PostgresDialect) SQLType ¶
func (db *PostgresDialect) SQLType(c *Column) string
func (*PostgresDialect) SupportEngine ¶
func (db *PostgresDialect) SupportEngine() bool
func (*PostgresDialect) TruncateDBTables ¶
func (db *PostgresDialect) TruncateDBTables() error
TruncateDBTables truncates all the tables. A special case is the dashboard_acl table where we keep the default permissions.
func (*PostgresDialect) UpdateTableSQL ¶
func (db *PostgresDialect) UpdateTableSQL(tableName string, columns []*Column) string
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) SQL ¶
func (m *RawSQLMigration) SQL(dialect Dialect) string
func (*RawSQLMigration) SQLite ¶
func (m *RawSQLMigration) SQLite(sql string) *RawSQLMigration
func (*RawSQLMigration) Set ¶
func (m *RawSQLMigration) Set(dialect string, 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) 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 (*SQLite3) AutoIncrStr ¶
func (*SQLite3) BooleanStr ¶
func (*SQLite3) DateTimeFunc ¶
func (*SQLite3) DropIndexSQL ¶
func (*SQLite3) ErrorMessage ¶
func (*SQLite3) IndexCheckSQL ¶
func (*SQLite3) IsDeadlock ¶
func (*SQLite3) IsUniqueConstraintViolation ¶
func (*SQLite3) SupportEngine ¶
func (*SQLite3) TruncateDBTables ¶
TruncateDBTables deletes all data from all the tables and resets the sequences. A special case is the dashboard_acl table where we keep the default permissions.
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.