Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3847] Migration only applies to the table not the model

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2016-06-21T18:38:42.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsmigration, model, sqlite
ReporterNeville Dastur
AssigneeShak Hossain
Created2016-06-14T22:53:20.000+0000
Updated2016-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

Comments

  1. Sharif AbuDarda 2016-06-15

    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.
  2. Neville Dastur 2016-06-15

    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
  3. Sharif AbuDarda 2016-06-21

    Reference Docs: http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Backbone_Migration

JSON Source