2014-03-10 13:28:04 +00:00
|
|
|
package migrate
|
|
|
|
|
|
|
|
type rev1st struct{}
|
|
|
|
|
|
|
|
var SetupTables = &rev1st{}
|
|
|
|
|
|
|
|
func (r *rev1st) Revision() int64 {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rev1st) Up(mg *MigrationDriver) error {
|
2014-03-13 11:53:52 +00:00
|
|
|
t := mg.T
|
2014-03-10 13:28:04 +00:00
|
|
|
if _, err := mg.CreateTable("users", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY, AUTOINCREMENT),
|
|
|
|
t.String("email", UNIQUE),
|
|
|
|
t.String("password"),
|
|
|
|
t.String("token", UNIQUE),
|
|
|
|
t.String("name"),
|
|
|
|
t.String("gravatar"),
|
|
|
|
t.Timestamp("created"),
|
|
|
|
t.Timestamp("updated"),
|
|
|
|
t.Bool("admin"),
|
|
|
|
t.String("github_login"),
|
|
|
|
t.String("github_token"),
|
|
|
|
t.String("bitbucket_login"),
|
|
|
|
t.String("bitbucket_token"),
|
|
|
|
t.String("bitbucket_secret"),
|
2014-03-10 13:28:04 +00:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := mg.CreateTable("teams", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY, AUTOINCREMENT),
|
|
|
|
t.String("slug", UNIQUE),
|
|
|
|
t.String("name"),
|
|
|
|
t.String("email"),
|
|
|
|
t.String("gravatar"),
|
|
|
|
t.Timestamp("created"),
|
|
|
|
t.Timestamp("updated"),
|
2014-03-10 13:28:04 +00:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := mg.CreateTable("members", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY, AUTOINCREMENT),
|
|
|
|
t.Integer("team_id"),
|
|
|
|
t.Integer("user_id"),
|
|
|
|
t.Integer("role"),
|
2014-03-10 13:28:04 +00:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := mg.CreateTable("repos", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY, AUTOINCREMENT),
|
|
|
|
t.Varchar("slug", 1024, UNIQUE),
|
|
|
|
t.String("host"),
|
|
|
|
t.String("owner"),
|
|
|
|
t.String("name"),
|
|
|
|
t.Bool("private"),
|
|
|
|
t.Bool("disabled"),
|
|
|
|
t.Bool("disabled_pr"),
|
|
|
|
t.Bool("priveleged"),
|
|
|
|
t.Integer("timeout"),
|
|
|
|
t.Varchar("scm", 25),
|
|
|
|
t.Varchar("url", 1024),
|
|
|
|
t.String("username"),
|
|
|
|
t.String("password"),
|
|
|
|
t.Varchar("public_key", 1024),
|
|
|
|
t.Varchar("private_key", 1024),
|
|
|
|
t.Varchar("params", 2000),
|
|
|
|
t.Timestamp("created"),
|
|
|
|
t.Timestamp("updated"),
|
|
|
|
t.Integer("user_id"),
|
|
|
|
t.Integer("team_id"),
|
2014-03-10 13:28:04 +00:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := mg.CreateTable("commits", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY, AUTOINCREMENT),
|
|
|
|
t.Integer("repo_id"),
|
|
|
|
t.String("status"),
|
|
|
|
t.Timestamp("started"),
|
|
|
|
t.Timestamp("finished"),
|
|
|
|
t.Integer("duration"),
|
|
|
|
t.Integer("attempts"),
|
|
|
|
t.String("hash"),
|
|
|
|
t.String("branch"),
|
|
|
|
t.String("pull_request"),
|
|
|
|
t.String("author"),
|
|
|
|
t.String("gravatar"),
|
|
|
|
t.String("timestamp"),
|
|
|
|
t.String("message"),
|
|
|
|
t.Timestamp("created"),
|
|
|
|
t.Timestamp("updated"),
|
2014-03-10 13:28:04 +00:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := mg.CreateTable("builds", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY, AUTOINCREMENT),
|
|
|
|
t.Integer("commit_id"),
|
|
|
|
t.String("slug"),
|
|
|
|
t.String("status"),
|
|
|
|
t.Timestamp("started"),
|
|
|
|
t.Timestamp("finished"),
|
|
|
|
t.Integer("duration"),
|
|
|
|
t.Timestamp("created"),
|
|
|
|
t.Timestamp("updated"),
|
|
|
|
t.Text("stdout"),
|
2014-03-10 13:28:04 +00:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := mg.CreateTable("settings", []string{
|
2014-03-13 11:53:52 +00:00
|
|
|
t.Integer("id", PRIMARYKEY),
|
|
|
|
t.String("github_key"),
|
|
|
|
t.String("github_secret"),
|
|
|
|
t.String("bitbucket_key"),
|
|
|
|
t.String("bitbucket_secret"),
|
|
|
|
t.Varchar("smtp_server", 1024),
|
|
|
|
t.Varchar("smtp_port", 5),
|
|
|
|
t.Varchar("smtp_address", 1024),
|
|
|
|
t.Varchar("smtp_username", 1024),
|
|
|
|
t.Varchar("smtp_password", 1024),
|
|
|
|
t.Varchar("hostname", 1024),
|
|
|
|
t.Varchar("scheme", 5),
|
2014-03-10 13:28:04 +00:00
|
|
|
})
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rev1st) Down(mg *MigrationDriver) error {
|
|
|
|
if _, err := mg.DropTable("settings"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := mg.DropTable("builds"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := mg.DropTable("commits"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := mg.DropTable("repos"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := mg.DropTable("members"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := mg.DropTable("teams"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err := mg.DropTable("users")
|
|
|
|
return err
|
|
|
|
}
|