See schema migration tools for django: http://code.djangoproject.com/wiki/SchemaEvolution
On 7 фев, 20:40, bobhaugen <[EMAIL PROTECTED]> wrote: > I am trying to evolve a Django project in piecemeal-growth fashion. > > I was happy to learn that I cd easily add tables to an existing model > using syncdb, but now I want to add a field. > > I read Django Fett's post about how to do it in this group, but I > cheated a little (see below excerpt). He wrote: > <excerpt> > Here are the steps I would use to add a field to an existing model > without having to write your own SQL and without the risk of getting > your model code out of sync with your database table... > Open up a Command Prompt window and change the drive/directory to your > project. Then do something similar to the following: > > > python manage.py dumpdata polls > polls.json > > python manage.py sqlclear polls > polls_drop.sql > > mysql -u root -p pypoll < polls_drop.sql > > enter your password for the root user (change for your specific > username) > > edit mysite/polls/models.py and add the field to the Poll model > > > python manage.py syncdb > > python manage.py loaddata polls.json > > </excerpt> > > I'm using Sqlite3. I cheated by doing: > 1. doing python manage.py dumpdata --indent=4 >mytest1.json > 2. putting mytest1.json in a fixtures directory under the mytest1 > project directory > 2. deleting the database file. > 3. recreating the database file as empty. > 4. adding the field to the model. > 5. doing python manage.py syncdb > 6. doing python manage.py loaddata mytest1.json > > Result: no data got loaded. > > So where did I go wrong? Was something critical about Django Fett's > mysql steps? In other words, is it critical to retain the existing > database to use dumpdata and loaddata successfully? > > Note: I'm at a really early stage, it is no trouble to recreate the > data. I'm just trying to learn because I am sure I will be doing this > again many times as this project evolves. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---