xavierlacot / joli.js

joli.js is an Activerecord-like javascript ORM, particularly suited for being used in the Appcelerator Titanium Mobile framework.
MIT License
267 stars 60 forks source link

Migration problem #16

Open jamesDin opened 12 years ago

jamesDin commented 12 years ago

First of all, I love your work !!! You really did a great job.

I tried your demo, and you have a line there that suppose to do "migrate" to database:

       joli.models.migrate(current_migration_version);

Actually, it runs ONLY on the first time, when the emulator/device is cleared. On the second time when I run it again, it gives an error on line 600 (joli.js). I checked it out and seems to be that after calling the next line:

    // use the model specified by as() first, then from()
    var model = joli.models.get(this.data.as || this.data.from);

the "model" is null. Then it fails on line 600:

   result.push(model.newRecord().fromArray(rowData));

When I comment the "migrate", line, the application works fine. But if joli can do this, it will be simply just great!

Thanks a lot.

sharpred commented 12 years ago

Pulled the latest version today (25/7/12) calling getVersion() throws the error Result of expression 'model' [undefined] is not an object. at joli.js (line 643)

result.push(model.newRecord().fromArray(rowData));

Which i assume is the same error as above other than the line number

jamesDin commented 12 years ago

Yes, that's exactly the problem. I wish there was a good "Data Migration" sample, I'm sure it's useful for all.