Created
February 7, 2013 13:51
-
-
Save tonylukasavage/4731041 to your computer and use it in GitHub Desktop.
This file contains 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
migration.up = function(migrator) { | |
migrator.createTable({ | |
columns: { | |
name: 'TEXT', | |
nickname: 'TEXT', | |
fighterId: 'INTEGER PRIMARY KEY' | |
} | |
}); | |
}; | |
migration.down = function(migrator) { | |
migrator.dropTable("fighters"); | |
}; |
This file contains 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
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]); | |
} | |
}; |
This file contains 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
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