From 8c83f2ab300c82e7856da3bf6bcdaf087f89e80d Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 1 Sep 2005 21:48:15 +0000 Subject: [PATCH] Added 'If I make changes to a model, how do I update the database?' to the FAQ git-svn-id: http://code.djangoproject.com/svn/django/trunk@594 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/faq.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/faq.txt b/docs/faq.txt index e1f909cea32..69991d49542 100644 --- a/docs/faq.txt +++ b/docs/faq.txt @@ -266,6 +266,23 @@ Using a ``FileField`` or an ``ImageField`` in a model takes a few steps: absolute URL to your image in a template with ``{{ object.get_mug_shot_url }}``. +If I make changes to a model, how do I update the database? +----------------------------------------------------------- + +If you don't care about clearing data, just do this:: + + django-admin.py sqlreset appname | psql dbname + +That "psql" assumes you're using PostgreSQL. If you're using MySQL, use the +appropriate command-line utility, ``mysql``. + +If you do care about deleting data, you'll have to execute the ``ALTER TABLE`` +statements manually in your database. That's the way we've always done it, +because dealing with data is a very sensitive operation that we've wanted to +avoid automating. That said, there's some work being done to add a +``django-admin.py updatedb`` command, which would output the necessary +``ALTER TABLE`` statements, if any. + The database API ================