Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What do you think about versioning with an ORM?

Doesn't this imply a automatic versioning with the rest of the code?

For example, I use Sequelize and create my tables via model classes, which I write like every other code in my app.



That works until a method you reference in the migration changes or doesn't exist anymore. For instance, a model you're working with might not expose some of the methods you're working with or a library has been modified, but it's being used in the migration. Obviously this is something that people should try to avoid, but I once found myself in the position of having to do checkout to some specific commits in the history in order to be able to run migrations at a past project. In the end I found myself repeating the process once too often and created a gem for it: https://github.com/hph/farfugl. This is for Rails migrations but the concept is the same in any library or language, you just have to go to the commit where the migration originates from.

As a side note, I've been using Sequelize for a year now and it can often be pretty annoying. Both the query interface and the migrations are subpar when compared to Rails. For instance:

    Model.find({ id: 1}) // or maybe just Model.find(1)!
vs. (the Sequelize syntax)

    Model.find({ where: { id: 1 } })
Forgetting the "where" above doesn't even raise an error, it just silently fails.


For IDs you can use

    Model.find(1)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: