Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
ponyorm migration tool #16
On Aug 7, 2013, at 11:51 AM, steinster email@example.com wrote:
referenced this issue
Oct 30, 2014
Hi guys, the task of writing good migration tools turns out to be more complex than I expected.
The delay was caused by the following reason: in current version of Pony some schema names are incompatible with a future migration tool.
One example is two entities
Another problematic situation is with a long names which don't fit within specified database maximum object name length. Current version of Pony just cut such names to maximum allowable length, but this can lead to situation when several different columns/foreign keys/indexes has the same name. The most problematic database in this aspect is Oracle, because in it the maximum name length cannot be greater than 30 chars. So even several independent columns can be erroneously cut to the same name. PostgreSQL and MySQL has less restrictive constraints of 63 and 64 max symbols in name, but even that may be not enough for automatically generated names of foreign keys and composite indexes. The correct solution is to add some unique md5 hash to the end of a truncated identifier name, if the length of the original name is too big.
The migration-enabled version of Pony will handle the names of tables, columns, foreign keys and indexes in that enhanced way. But what to do with existing databases? We think they should be upgraded to this new naming standard before migrations can be applied to them. In order to do that, we add a new system table
At this moment we have correct implementation of that upgrade logic for all supported databases, and also implementation of the migration tool. What rest is to combine upgrade logic and migration logic together and propose some API which will be convenient to user. We plan to replace
Resuming, we actively working on migration tool, but my estimates about the time it requires to be implemented turn out to be completely incorrect. I think the work on migration tool is finished on 90% at this moment, but it will be unrealistically to say we can release migrations during this week. I really hope we can release it during the following week, but as history has shown, it is very hard to give correct estimations about the time required for implementing of such a complex tool as migration support. But we are working on it, and I think the final is already close.
Hi, I just pushed a new branch orm-migrations with the first version of PonyORM migrations. You can read the description of API here: https://github.com/ponyorm/pony/tree/orm-migrations/pony/migrate
The code is very raw at this point and not intended for production usage yet, we still need to work on it. I think really simple use-cases for PostgreSQL and MySQL should work, but SQLite support is limited, and merge functionality is untested. Adding entity or attribute should work, but, say, changing inheritance hierarchy or modifying a type of relationship will raise NotImplementedError. Anyway, I hope the working version of migrations is close.
I can confirm that migrations is working, if you want to install it via pip currently do the following
All the documentation on how to do migration can be found here
Also if you are using pony with flask blueprints, please note ref another issue