Re: manage.py reset and custom sql

2009-09-03 Thread Russell Keith-Magee

On Thu, Sep 3, 2009 at 5:10 PM, Anssi Kaariainen wrote:
>
> Hello all,
>
> The problem I am trying to solve is this: I have defined some views
> and corresponding models with managed = False. Now when I issue
> manage.py reset I get an error because the views block dropping the
> tables. I need to manually drop the views before I issue manage.py
> reset.
>
> I am thinking of implementing a patch for this. This would be my first
> patch for Django. The idea for the patch is simple: now there is
> sqlcustom, which looks for a file in "/sql/.sql"
> for each model. I would add sqlcustomdrop (better name needed?)
> command which would look for sql in "/sql/
> .drop.sql". This would be run before any django generated
> drop table commands would be run.
>
> Is there some nice way to achieve this already in Django? And is this
> something that would be useful for Django core? Any feedback would be
> nice before I start working on this.

No, Django doesn't provide any way to do this at present.

While I appreciate your enthusiasm here, and there's nothing
fundamentally wrong with the design you propose, I wouldn't advise
spending too much time trying to fix reset. Django provides reset
mostly for historical reasons. It has some major flaws - circular
cross application dependencies, for example, can completely break a
call to reset.

We haven't officially deprecated reset, but that's only because we
aren't in a position to provide an alternative. The real alternative
is a built-in schema evolution framework, and as soon as Django is in
a position to add one, I would expect to see reset deprecated. Given
that it is on the path to deprecation, there isn't much incentive for
the core team to spend time adding features to the reset command.

Suffice to say, if you're creating and dropping your tables all the
time rather than using ALTER TABLE or a schema evolution framework
(e.g., South or Django Evolution), You're Doing It Wrong (tm) :-)

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



manage.py reset and custom sql

2009-09-03 Thread Anssi Kaariainen

Hello all,

The problem I am trying to solve is this: I have defined some views
and corresponding models with managed = False. Now when I issue
manage.py reset I get an error because the views block dropping the
tables. I need to manually drop the views before I issue manage.py
reset.

I am thinking of implementing a patch for this. This would be my first
patch for Django. The idea for the patch is simple: now there is
sqlcustom, which looks for a file in "/sql/.sql"
for each model. I would add sqlcustomdrop (better name needed?)
command which would look for sql in "/sql/
.drop.sql". This would be run before any django generated
drop table commands would be run.

Is there some nice way to achieve this already in Django? And is this
something that would be useful for Django core? Any feedback would be
nice before I start working on this.

Anssi Kääriäinen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---