Skip to content

Instantly share code, notes, and snippets.

@emilsjolander
Created April 5, 2014 12:14
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save emilsjolander/9991234 to your computer and use it in GitHub Desktop.
spinkles new migration api
void onCreate() {
Sprinkles s = Sprinkles.init(this);
s.registerTypeSerializer(...)
s.registerTypeSerializer(...)
s.registerModel(Note.class)
}
void onCreate() {
Sprinkles s = Sprinkles.init(this);
s.registerTypeSerializer(...)
s.registerTypeSerializer(...)
s.migrate(Migration.createTable(Note.class,
new Migrator() {
void onMigrate(CreateTableMigration m) {
m.addColumn("id")
m.addColumn("title")
m.addColumn("color")
m.addColumn("tag_id")
}
}
));
}
void onCreate() {
Sprinkles s = Sprinkles.init(this);
s.registerTypeSerializer(...)
s.registerTypeSerializer(...)
s.migrate(Migration.createTable("Notes",
new Migrator() {
void onMigrate(CreateTableMigration m) {
m.addColumn("id", long.class).constraints(Constraint.primaryKey(), Constraint.autoincrement());
m.addColumn("title", String.class).constraints(Constraint.notNull());
m.addColumn("color", Color.class)
m.addColumn("tag_id", long.class).constraints(Constraint.foriegnKey("Tags","id"))
}
}
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment