Re: Show diff between fresh and running database schema

2008-04-23 Thread Malcolm Tredinnick


On Wed, 2008-04-23 at 17:18 +0200, Thomas Guettler wrote:
> Malcolm Tredinnick schrieb:
> > On Wed, 2008-04-23 at 15:37 +0200, Thomas Guettler wrote:
> >   
> >> Hi,
> >>
> >> has some one a script to show the difference between the
> >> running database and one which get created by syncdb?
> >>
> >>
> >> 
> > This sounds like it would be really difficult (complex) to make it work
> > correctly. The output from a database tool is going to include stuff
> > that you don't necessarily care about (e.g. constraints that are
> > auto-created with names in some cases), the table ordering may well be
> > different,
> The ordering of the columns is why I needed the diff in my case!

No, I said the ordering of the tables, not the ordering of the columns.
The order that Django creates the tables isn't necessarily going to be
the order they are output by pg_dump. Also, if you add a new table to a
database, is it possible the order of the tables as output by pg_dump
will change?

What I'm trying to get at here is that I think that a general solution
needs to be much more aware of things than just the output. It needs to
actually understand the output and known how to relate like things to
like. For all the database backends it supports, and that's why it's
harder than it looks.

Regards,
Malcolm

-- 
I intend to live forever - so far so good. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Show diff between fresh and running database schema

2008-04-23 Thread Thomas Guettler

Malcolm Tredinnick schrieb:
> On Wed, 2008-04-23 at 15:37 +0200, Thomas Guettler wrote:
>   
>> Hi,
>>
>> has some one a script to show the difference between the
>> running database and one which get created by syncdb?
>>
>>
>> 
> This sounds like it would be really difficult (complex) to make it work
> correctly. The output from a database tool is going to include stuff
> that you don't necessarily care about (e.g. constraints that are
> auto-created with names in some cases), the table ordering may well be
> different,
The ordering of the columns is why I needed the diff in my case!

I use psycopg2 copy_to and copy_from to dump some data
from the production database into the test database. This failed,
because the ordering changed.

> I'm not
> sure that comparing the output of one tool with the output of an
> entirely different tool to check for differences is going to be a robust
> solution.
>   
Both files are created with the same tool: pg_dump -s.
The diff of both files helped me to find the solution.

Thank you Malcolm for your great work!
  Thomas

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


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Show diff between fresh and running database schema

2008-04-23 Thread Malcolm Tredinnick


On Wed, 2008-04-23 at 15:37 +0200, Thomas Guettler wrote:
> Hi,
> 
> has some one a script to show the difference between the
> running database and one which get created by syncdb?
> 
> Up to now, I used the output of sqlall before and after
> a model change. But it would be better to do the
> diff of the running database.
> 
> Up to now I do it like this:
> 
> pg_dump -s databasename > running.schema
> ./manage.py test myapp # Hit ctrl-c after test database was created.
> pg_dump -s test_databasename > test.schema
> diff test.schema running.schema
> 
> Maybe something like this be implemented as new management command ...

This sounds like it would be really difficult (complex) to make it work
correctly. The output from a database tool is going to include stuff
that you don't necessarily care about (e.g. constraints that are
auto-created with names in some cases), the table ordering may well be
different, models don't necessarily include all the fields in a database
table... there's a whole maze of things that could be different. I'm not
sure that comparing the output of one tool with the output of an
entirely different tool to check for differences is going to be a robust
solution.

I think your current approach is a lot safer, since you at least
understand the expected differences.

Regards,
Malcolm
-- 
Experience is something you don't get until just after you need it. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Show diff between fresh and running database schema

2008-04-23 Thread Thomas Guettler

Hi,

has some one a script to show the difference between the
running database and one which get created by syncdb?

Up to now, I used the output of sqlall before and after
a model change. But it would be better to do the
diff of the running database.

Up to now I do it like this:

pg_dump -s databasename > running.schema
./manage.py test myapp # Hit ctrl-c after test database was created.
pg_dump -s test_databasename > test.schema
diff test.schema running.schema

Maybe something like this be implemented as new management command ...

Any volunteers? Since pg_dump is only available for postgres, you
would need something like for other DBs, too.

 Thomas

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


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---