[PonyORM-list] How to deal with schema change ?
alexeymalashkevich at gmail.com
Wed Sep 3 21:17:30 UTC 2014
We are planning to add a migration tool, hopefully by the end of this year.
With this tool one will be able to change their entity definition and then
python -m pony.migrate myentities.py
and have the database updated automatically.
But before this tool is ready, you need to prepare a script which updates
your tables using ‘ALTER TABLE’ commands manually and then execute it
your database. You can create a separate program and use the db.execute()
method for executing the script,
see http://doc.ponyorm.com/database.html#Database.execute for details.
In this program you don’t need to map your entities, just connect to your
database and run a script which updates your tables.
Basically, at the moment, the approach is the following: make changes to
your entities definitions, update tables accordingly and then run the
updated version of your application.
After you have your entity definitions updated, you can get the script
which Pony uses for tables creation using the
method, and compare it with the previous one. This can help you to see what
columns need to be updated.
On Wed, Sep 3, 2014 at 1:14 PM, stephane martin <stef.martin at gmail.com>
> i googled a bit before, but cant find good ressource about it, so....
> How am i supposed to deal with schema change ?
> Let's say i develop an app. In v0.1, i design some database schema
> with db.Entity. Everything works fine, users are happy, and the
> database gets some data.
> Then maybe i'll have a feature request, and I will have to add some
> field to some Entity. Or maybe i will need to change some field type
> from unicode to datetime, etc.
> What is most correct approach to migrate my data to the new schema ?
> Many thanks and kind regards,
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ponyorm-list