Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonylukasavage/4731041 to your computer and use it in GitHub Desktop.
Save tonylukasavage/4731041 to your computer and use it in GitHub Desktop.
migration.up = function(migrator) {
migrator.createTable({
columns: {
name: 'TEXT',
nickname: 'TEXT',
fighterId: 'INTEGER PRIMARY KEY'
}
});
};
migration.down = function(migrator) {
migrator.dropTable("fighters");
};
var fighters = [
{ name: 'Wanderlei Silva', nickname: 'The Axe Murderer', fighterId: 7 },
{ name: 'Manny Pacquiao', nickname: 'Pac-Man', fighterId: 1234 },
{ name: 'Muhammad Ali', nickname: 'The Greatest', fighterId: 999 }
];
migration.up = function(migrator) {
for (var i = 0; i < fighters.length; i++) {
migrator.insertRow(fighters[i]);
}
};
migration.down = function(migrator) {
for (var i = 0; i < fighters.length; i++) {
migrator.deleteRow(fighters[i]);
}
};
exports.definition = {
config: {
"columns": {
name: 'TEXT',
nickname: 'TEXT',
// column values can have types with keywords
fighterId: 'INTEGER PRIMARY KEY'
},
"adapter": {
"type": "sql",
// The table name inside the sqlite database to use for
// models and collections based on this definition.
"collection_name": "fighters",
// idAttribute tells Alloy/Backbone to use this column in
// my table as its unique identifier field. Without
// specifying this, Alloy's default behavior is to create
// and "alloy_id" field which will uniquely identify your
// rows in the table with a text GUID.
"idAttribute": "fighterId"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment