Diff frozen model and real DB

2 views
Skip to first unread message

Thomas Guettler

unread,
Dec 2, 2009, 7:14:02 AM12/2/09
to south...@googlegroups.com
Hi,

I am unsure if the frozen model really looks
like my database tables. Is there a way to
check this?

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

Andrew Godwin

unread,
Dec 2, 2009, 8:55:53 AM12/2/09
to south...@googlegroups.com
Do:

./manage.py startmigration --auto appname --stdout

That will print the migration it would make to stdout, so you can see
what changes it needs to make. If there aren't any differences, it will
print "nothing seems to have changed".

Andrew

Thomas Guettler

unread,
Dec 4, 2009, 5:04:53 AM12/4/09
to south...@googlegroups.com


Andrew Godwin wrote:
> Do:
>
> ./manage.py startmigration --auto appname --stdout
>
> That will print the migration it would make to stdout, so you can see
> what changes it needs to make. If there aren't any differences, it will
> print "nothing seems to have changed".

I think this will compare the models.py files with the last frozen model.
But I want to compare the real database. I tried it with "ALTER TABLE .. ADD COLUMN"
and --auto didn't find my modification to the database.

I know it would be hard
or even impossible to find all changes that could happen to the database.
But at least tables, columns, column types and column length (varchar) would be nice.

Django already provides introspection methods. Although they sometimes produce wrong
results if you drop columns. After a complete dump+restore it is correct again. (Postgres 8.2.14).

Andrew Godwin

unread,
Dec 4, 2009, 5:12:19 AM12/4/09
to south...@googlegroups.com
Oh, the _real database_? No, we don't do that; introspection of a
database is a long and painful road to go down, and it's just not in the
current design scope of South.

If your database is out of sync with your models, it's your job to either:
a) Write migrations manually - they're just python files, and
startmigration will happily make blank template ones
b) Fix your models so they match

Django's introspection code simply isn't good enough for most cases, and
even if it were, doing comparison against database types with field
classes is just painful - comparing two sets of models is complex enough
as it is.

Basically, this feature might get added when everything else is done and
dusted and I live a happy and boring life, but until then, it won't :)

Andrew
Reply all
Reply to author
Forward
0 new messages