Documentation ¶
Index ¶
Constants ¶
View Source
const ( UNIQUE int = iota PRIMARYKEY AUTOINCREMENT NULL NOTNULL )
Variables ¶
View Source
var AddGitlabColumns = &rev20140328201430{}
View Source
var AddOpenInvitationColumn = &rev20140310104446{}
View Source
var GitHubEnterpriseSupport = &Rev3{}
View Source
var RenamePrivelegedToPrivileged = &Rev1{}
View Source
var SaveDroneYml = &rev20140522205400{}
View Source
var SetupIndices = &rev2nd{}
View Source
var SetupTables = &rev1st{}
Functions ¶
This section is empty.
Types ¶
type DriverBuilder ¶ added in v0.2.1
type DriverBuilder func(tx *sql.Tx) *MigrationDriver
DriverBuilder is a constructor for MigrationDriver
var Driver DriverBuilder
type Migration ¶
type Migration struct {
// contains filtered or unexported fields
}
func (*Migration) All ¶
All is called to collect all migration scripts and adds them to Revision list. New Revision should be added here ordered by its revision number.
type MigrationDriver ¶
MigrationDriver drives migration script by injecting transaction object (*sql.Tx), `Operation` implementation and column type helper.
func MySQL ¶ added in v0.2.1
func MySQL(tx *sql.Tx) *MigrationDriver
func PostgreSQL ¶ added in v0.2.1
func PostgreSQL(tx *sql.Tx) *MigrationDriver
func SQLite ¶
func SQLite(tx *sql.Tx) *MigrationDriver
type Operation ¶
type Operation interface { // CreateTable may be used to create a table named `tableName` // with its columns specification listed in `args` as an array of string CreateTable(tableName string, args []string) (sql.Result, error) // RenameTable simply rename table from `tableName` to `newName` RenameTable(tableName, newName string) (sql.Result, error) // DropTable drops table named `tableName` DropTable(tableName string) (sql.Result, error) // AddColumn adds single new column to `tableName`, columnSpec is // a standard column definition (column name included) which may looks like this: // // mg.AddColumn("example", "email VARCHAR(255) UNIQUE") // // it's equivalent to: // // mg.AddColumn("example", mg.T.String("email", UNIQUE)) // AddColumn(tableName, columnSpec string) (sql.Result, error) // ChangeColumn may be used to change the type of a column // `newType` should always specify the column's new type even // if the type is not meant to be change. Eg. // // mg.ChangeColumn("example", "name", "VARCHAR(255) UNIQUE") // ChangeColumn(tableName, columnName, newType string) (sql.Result, error) // DropColumns drops a list of columns DropColumns(tableName string, columnsToDrop ...string) (sql.Result, error) // RenameColumns will rename columns listed in `columnChanges` RenameColumns(tableName string, columnChanges map[string]string) (sql.Result, error) // AddIndex adds index on `tableName` indexed by `columns` AddIndex(tableName string, columns []string, flags ...string) (sql.Result, error) // DropIndex drops index indexed by `columns` from `tableName` DropIndex(tableName string, columns []string) (sql.Result, error) }
Operation interface covers basic migration operations. Implementation details is specific for each database, see migrate/sqlite.go for implementation reference.
type Rev1 ¶
type Rev1 struct{}
func (*Rev1) Down ¶
func (r *Rev1) Down(mg *MigrationDriver) error
func (*Rev1) Up ¶
func (r *Rev1) Up(mg *MigrationDriver) error
type Rev3 ¶
type Rev3 struct{}
func (*Rev3) Down ¶
func (r *Rev3) Down(mg *MigrationDriver) error
func (*Rev3) Up ¶
func (r *Rev3) Up(mg *MigrationDriver) error
type Revision ¶
type Revision interface { Up(mg *MigrationDriver) error Down(mg *MigrationDriver) error Revision() int64 }
Source Files ¶
- 1_setup_tables.go
- 201402200603_rename_privelege_to_privilege.go
- 201402211147_github_enterprise_support.go
- 20140310104446_add_open_invitation_column.go
- 20140328201430_add_gitlab_columns.go
- 20140522205400_save_drone_yml.go
- 2_setup_indices.go
- all.go
- api.go
- column_type.go
- migrate.go
- mysql.go
- postgresql.go
- sqlite.go
- util.go
Click to show internal directories.
Click to hide internal directories.