[AC-3847] Migration only applies to the table not the model
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2016-06-21T18:38:42.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Alloy |
Labels | migration, model, sqlite |
Reporter | Neville Dastur |
Assignee | Shak Hossain |
Created | 2016-06-14T22:53:20.000+0000 |
Updated | 2016-06-21T18:38:42.000+0000 |
Description
I had a migration using:
migration.up = function(migrator) {
migrator.db.execute('ALTER TABLE ' + migrator.table + ' ADD COLUMN new_col INT;');
};
This successfully adds the new column to the sqlite database, however models basedon the table can not be manipulated.
For example
var Model = Alloy.createModel('mymodel');
Model.fetch({id: chat.from.id});
Model.set({
"new_col": 1
});
Model.save();
Will fail
Hello, Can you explain a little more about your issue? Please provide separate sample code to test for database and for Alloy model. We will test the sample to reproduce the issue in our environment. Also, Please provide complete steps to follow for successful regeneration. Regards, Sharif.
Okay, realised not a bug but rather a documentation problem. I haven't tried but I didn't update the backbone model definition which must have been the cause. I think it would be worth adding to the docs to described the migration file but also that the new column need to be added to the Alloy model file
Reference Docs: http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Backbone_Migration