github.com/marinho/drone@v0.2.1-0.20140504195434-d3ba962e89a7/pkg/database/migrate/2_setup_indices.go (about) 1 package migrate 2 3 type rev2nd struct{} 4 5 var SetupIndices = &rev2nd{} 6 7 func (r *rev2nd) Revision() int64 { 8 return 2 9 } 10 11 func (r *rev2nd) Up(mg *MigrationDriver) error { 12 if _, err := mg.AddIndex("members", []string{"team_id", "user_id"}, "unique"); err != nil { 13 return err 14 } 15 16 if _, err := mg.AddIndex("members", []string{"team_id"}); err != nil { 17 return err 18 } 19 20 if _, err := mg.AddIndex("members", []string{"user_id"}); err != nil { 21 return err 22 } 23 24 if _, err := mg.AddIndex("commits", []string{"repo_id", "hash", "branch"}, "unique"); err != nil { 25 return err 26 } 27 28 if _, err := mg.AddIndex("commits", []string{"repo_id"}); err != nil { 29 return err 30 } 31 32 if _, err := mg.AddIndex("commits", []string{"repo_id", "branch"}); err != nil { 33 return err 34 } 35 36 if _, err := mg.AddIndex("repos", []string{"team_id"}); err != nil { 37 return err 38 } 39 40 if _, err := mg.AddIndex("repos", []string{"user_id"}); err != nil { 41 return err 42 } 43 44 if _, err := mg.AddIndex("builds", []string{"commit_id"}); err != nil { 45 return err 46 } 47 48 _, err := mg.AddIndex("builds", []string{"commit_id", "slug"}) 49 50 return err 51 } 52 53 func (r *rev2nd) Down(mg *MigrationDriver) error { 54 if _, err := mg.DropIndex("builds", []string{"commit_id", "slug"}); err != nil { 55 return err 56 } 57 if _, err := mg.DropIndex("builds", []string{"commit_id"}); err != nil { 58 return err 59 } 60 if _, err := mg.DropIndex("repos", []string{"user_id"}); err != nil { 61 return err 62 } 63 if _, err := mg.DropIndex("repos", []string{"team_id"}); err != nil { 64 return err 65 } 66 if _, err := mg.DropIndex("commits", []string{"repo_id", "branch"}); err != nil { 67 return err 68 } 69 if _, err := mg.DropIndex("commits", []string{"repo_id"}); err != nil { 70 return err 71 } 72 if _, err := mg.DropIndex("commits", []string{"repo_id", "hash", "branch"}); err != nil { 73 return err 74 } 75 if _, err := mg.DropIndex("members", []string{"user_id"}); err != nil { 76 return err 77 } 78 if _, err := mg.DropIndex("members", []string{"team_id"}); err != nil { 79 return err 80 } 81 _, err := mg.DropIndex("members", []string{"team_id", "user_id"}) 82 return err 83 }