Whats the procedure to create a new table on a existing app with an already installed db? I'm doing like this:
This is the new table that needs to be created:
exports.definition = { config : { "columns" : { "name" : "string", "id" : "int" }, adapter : { type : "sql", db_file : "/db.sqlite", collection_name : "books", idAttribute : "id" } } };Migration:
20131112000000_books.js
migration.up = function(migrator) { migrator.db.execute("CREATE TABLE IF NOT EXISTS books (name TEXT NOT NULL, id INTEGER NOT NULL );"); }; migration.down = function(migrator) { migrator.db.execute("DROP TABLE IF EXISTS books;"); };In the app I do:
var books = Alloy.createCollection('books');And I get:
12-11 19:04:30.728: E/TiExceptionHandler(13828): (main) [366,366] ----- Titanium Javascript Runtime Error ----- 12-11 19:04:30.728: E/TiExceptionHandler(13828): (main) [0,366] - In alloy/sync/sql.js:11,69 12-11 19:04:30.733: E/TiExceptionHandler(13828): (main) [1,367] - Message: Uncaught TypeError: Cannot call method 'isValidRow' of null 12-11 19:04:30.733: E/TiExceptionHandler(13828): (main) [0,367] - Source: base.install(b,d),d=b.execute('pragma table_info("'+e+'");'),f={};d.isValidRow 12-11 19:04:30.733: E/V8Exception(13828): Exception occurred at alloy/sync/sql.js:11: Uncaught TypeError: Cannot call method 'isValidRow' of nullBecause Alloy is executing "installDatabase" in the sql adapter with the parameter "config.adapter.collection_name" equal to "books", so it tries to check the "pragma table_info" of a table that doesnt exists yet, the migration is not executed before