1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/pkg/database/migrate/20140328201430_add_gitlab_columns.go
2014-03-29 11:51:02 +00:00

40 lines
1019 B
Go

package migrate
type rev20140328201430 struct{}
var AddGitlabColumns = &rev20140328201430{}
func (r *rev20140328201430) Revision() int64 {
return 20140328201430
}
func (r *rev20140328201430) Up(mg *MigrationDriver) error {
// Migration steps here
if _, err := mg.AddColumn("settings", mg.T.String("gitlab_domain")); err != nil {
return err
}
if _, err := mg.AddColumn("settings", mg.T.String("gitlab_apiurl")); err != nil {
return err
}
if _, err := mg.Tx.Exec(`update settings set gitlab_domain=?`, "gitlab.com"); err != nil {
return err
}
if _, err := mg.Tx.Exec(`update settings set gitlab_apiurl=?`, "https://gitlab.com"); err != nil {
return err
}
_, err := mg.AddColumn("users", mg.T.String("gitlab_token"))
return err
}
func (r *rev20140328201430) Down(mg *MigrationDriver) error {
// Revert migration steps here
if _, err := mg.DropColumns("users", "gitlab_token"); err != nil {
return err
}
_, err := mg.DropColumns("settings", "gitlab_domain", "gitlab_apiurl")
return err
}