Sunday, May 30, 2010

Re: How can I test the correctness of my models against the schema of a database?

Not really.

If you're specially working with legacy databases trying to figure out that do
Django models match underlying schema is PITA.

We resolved this partially by doing few simple tests, namely running through
all models and doing empty query. Since Django ORM queries for every field it
revealed most of the problems right away. Of course we didn't checked lenghts
or types of field.

Also this could be useful in development phase when you add new fields.

In django-command-extensions exists dbdiff command which produces somekind of
diff against underlying database but it's in very early stages.

> Sorry. I haven't use other methods for that.
> But isn't it enough to test it using loremiser or something like that
> and like an addition debug toolbar?
>
> On May 31, 12:53 am, David Horat <david.ho...@gmail.com> wrote:
> > Dear group,
> >
> > How can I test the correctness of my models against the schema of a
> > database?
> >
> > To solve this question, I have tried unsuccessfully several options:
> > - Using ./manage.py test triggers the creation and destruction of a
> > database, but I want to check the correctness of the model against a
> > production database, since I just want to check the schema, not the
> > content.
> > - Creating my own test runner as specified
> > herehttp://stackoverflow.com/questions/138851 which basically hacks the
> > Django stack and gives you other problems. In any case this seems not to
> > be the correct way.
> >
> > Has anyone of you faced this situation before? Any clues?
> >
> > Thank you in advance.
> >
> > Best Regards,
> > David Horat

--

Jani Tiainen

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment