Created
December 17, 2014 20:00
-
-
Save bithavoc/87b7d34629a65f397efb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // http://github.com/ride/go-migrate | |
| type MigrationHandler func(context *migrate.Context) error | |
| type core.Migration struct { | |
| Up: MigrationHandler, | |
| Down: MigrationHandler, | |
| Name: "Something cool", | |
| } | |
| func main() { | |
| migrations := migrate.Migrations { | |
| Migrations: []migrate.Migration { | |
| { | |
| Name: "Create persons table", | |
| Up: func(context *migrate.Context) error { | |
| return context.DataDefinition(`CREATE TABLE people { id uuid PRIMARY KEY, title text, title text, data blob};`) | |
| }, | |
| Down: func(context *migrate.Context) error { | |
| return context.DataDefinition(`DROP TABLE people;`) | |
| } | |
| }, | |
| { | |
| Name: "add persons name", | |
| Up: func(context *migrate.Context) error { | |
| return context.DataDefinition(`ALTER TABLE people ADD COLUMN name text;`) | |
| }, | |
| Down: func(context *migrate.Context) error { | |
| return context.DataDefinition(`ALTER TABLE people DROP COLUMN name;`) | |
| } | |
| }, | |
| }, | |
| } | |
| err := migrategocql.Configure(migrations).WithCluster("127.0.0.1") | |
| if err != nil { | |
| panic(err) | |
| } | |
| err, command := migrations.ExecuteWithDefaultCommand(&migrate.Migrate) // migrate.Migrate() | |
| if err != nil { | |
| panic(err) | |
| } | |
| } | |
| // IN-PROCESS | |
| app --migrations-rollback=1 | |
| app --migrations-redo=1 | |
| app --migrations-ensure | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment