2014-03-10 00:08:58 +00:00
|
|
|
package migrate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Operation interface covers basic migration operations.
|
|
|
|
// Implementation details is specific for each database,
|
|
|
|
// see migrate/sqlite.go for implementation reference.
|
|
|
|
type Operation interface {
|
|
|
|
CreateTable(tableName string, args []string) (sql.Result, error)
|
|
|
|
|
|
|
|
RenameTable(tableName, newName string) (sql.Result, error)
|
|
|
|
|
|
|
|
DropTable(tableName string) (sql.Result, error)
|
|
|
|
|
|
|
|
AddColumn(tableName, columnSpec string) (sql.Result, error)
|
|
|
|
|
|
|
|
ChangeColumn(tableName, columnName, newType string) (sql.Result, error)
|
|
|
|
|
|
|
|
DropColumns(tableName string, columnsToDrop []string) (sql.Result, error)
|
|
|
|
|
|
|
|
RenameColumns(tableName string, columnChanges map[string]string) (sql.Result, error)
|
|
|
|
|
2014-03-13 19:14:16 +00:00
|
|
|
AddIndex(tableName string, columns []string, flags ...string) (sql.Result, error)
|
2014-03-10 00:08:58 +00:00
|
|
|
|
2014-03-10 04:30:39 +00:00
|
|
|
DropIndex(tableName string, columns []string) (sql.Result, error)
|
2014-03-10 00:08:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type MigrationDriver struct {
|
|
|
|
Operation
|
2014-03-13 11:53:52 +00:00
|
|
|
T *columnType
|
|
|
|
Tx *sql.Tx
|
2014-03-10 00:08:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DriverBuilder func(tx *sql.Tx) *MigrationDriver
|