<div dir="ltr"><div><div>Hi Stephane!</div><div><br></div><div>We are planning to add a migration tool, hopefully by the end of this year. </div><div>With this tool one will be able to change their entity definition and then run</div>
<div><br></div><div>python -m pony.migrate myentities.py</div><div><br></div><div>and have the database updated automatically.</div><div><br></div><div>But before this tool is ready, you need to prepare a script which updates </div>
<div>your tables using ‘ALTER TABLE’ commands manually and then execute it against </div><div>your database. You can create a separate program and use the db.execute() </div><div>method for executing the script, </div><div>
see <a href="http://doc.ponyorm.com/database.html#Database.execute">http://doc.ponyorm.com/database.html#Database.execute</a> for details. </div><div>In this program you don’t need to map your entities, just connect to your </div>
<div>database and run a script which updates your tables.</div><div><br></div><div>Basically, at the moment, the approach is the following: make changes to </div><div>your entities definitions, update tables accordingly and then run the </div>
<div>updated version of your application.</div><div><br></div><div>After you have your entity definitions updated, you can get the script </div><div>which Pony uses for tables creation using the `db.schema.generate_create_script()` </div>
<div>method, and compare it with the previous one. This can help you to see what </div><div>columns need to be updated.</div></div><div><br></div><div>Regards,</div><div>Alexey</div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Wed, Sep 3, 2014 at 1:14 PM, stephane martin <span dir="ltr"><<a href="mailto:stef.martin@gmail.com" target="_blank">stef.martin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
i googled a bit before, but cant find good ressource about it, so....<br>
<br>
How am i supposed to deal with schema change ?<br>
<br>
Let's say i develop an app. In v0.1, i design some database schema<br>
with db.Entity. Everything works fine, users are happy, and the<br>
database gets some data.<br>
<br>
Then maybe i'll have a feature request, and I will have to add some<br>
field to some Entity. Or maybe i will need to change some field type<br>
from unicode to datetime, etc.<br>
<br>
What is most correct approach to migrate my data to the new schema ?<br>
<br>
Many thanks and kind regards,<br>
Stephane<br>
_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
<a href="/ponyorm-list" target="_blank">/ponyorm-list</a><br>
</blockquote></div><br></div>