2014-03-29 09:37:50 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2014-03-29 14:51:02 +03:00
|
|
|
if _, err := mg.Tx.Exec(`update settings set gitlab_domain=?`, "gitlab.com"); err != nil {
|
2014-03-29 09:37:50 +03:00
|
|
|
return err
|
|
|
|
}
|
2014-03-29 14:51:02 +03:00
|
|
|
|
|
|
|
if _, err := mg.Tx.Exec(`update settings set gitlab_apiurl=?`, "https://gitlab.com"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2014-03-31 00:32:20 +03:00
|
|
|
if _, err := mg.AddColumn("users", mg.T.String("gitlab_token")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := mg.Tx.Exec(`update users set gitlab_token=?`, "")
|
2014-03-29 09:37:50 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rev20140328201430) Down(mg *MigrationDriver) error {
|
|
|
|
// Revert migration steps here
|
|
|
|
if _, err := mg.DropColumns("users", "gitlab_token"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-03-29 14:51:02 +03:00
|
|
|
_, err := mg.DropColumns("settings", "gitlab_domain", "gitlab_apiurl")
|
2014-03-29 09:37:50 +03:00
|
|
|
return err
|
|
|
|
}
|