mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-18 08:26:45 +02:00
7cf4f2eb89
Requirements: MySQL/MariaDB need to be configured with this settings: innodb_file_format = Barracuda innodb_file_per_table = On innodb_large_prefix = On to support key prefix length up to 3042 bytes. MySQL/MariaDB DSN will need this parameter: parseTime=true as per [1] The migration system itself mostly inspired by Rails (ActiveRecord), but it still rough at the edges. Could use some inputs. Next Todo: more testing! [1] https://github.com/go-sql-driver/mysql#parsetime
37 lines
998 B
Go
37 lines
998 B
Go
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)
|
|
|
|
AddIndex(tableName string, columns []string, flags ...string) (sql.Result, error)
|
|
|
|
DropIndex(tableName string, columns []string) (sql.Result, error)
|
|
}
|
|
|
|
type MigrationDriver struct {
|
|
Operation
|
|
T *columnType
|
|
Tx *sql.Tx
|
|
}
|
|
|
|
type DriverBuilder func(tx *sql.Tx) *MigrationDriver
|