On Thu, Sep 01, 2005 at 10:59:12AM -0500, Brant Harris wrote:
> field in a table needs to be changed. In MySQL it seems to be
> relatively easy to figure it out with DESCRIBE table; harder in
> Postgres; and I believe impossible in SQLite. So there are two ideas
> from there:
I think you've missed the sane third possibility, which is to fail
(nicely, of course) when the request can't be fulfilled.
> One is to add a keyword option for the fields in the model syntax,
-1 Nasty hackish solution (we can't make it work, really, so we'll
add an override and leave it up to you to somehow figure out where to
invoke it. You *did* backup your data before trying this, right?). If
you have to do it that way, at least don't add the (correct once) flags
to the schema itself. It's a throwaway list, so *make* it just that,
and feed it into the change command however you like. I might get to
-0 for that. I doubt I'd care to use it.
> The other idea is to have it CHANGE every single field, regardless of
> whether or not it needs to be. Here the logic goes that if you CHANGE
> a field to what it already is, nothing occurs, meanwhile all the ones
> that need to be changed are. This however, extremely bloats the SQL
> code shot back from database_check.
At least. And who knows if it will really be a no-op for every
database? And thatstill fails for some cases, especially column
renamings (as you preovided an example of). -1
> There are some other problems in making this a single-step process.
Yes indeed. Like for example that it is in general NOT a single-step
process! Sometimes you *have* *to* make a partial change, futz with
things, then complete the change. The sane way to do that, IMO, is to
manipulate the database using a language designed for database
manipulation (eg., SQL), then get Django's model back in sync. The
alternative (that would work in general) would be to add all the
functionality of SQL to what is presently a simpler langauge designed
only to describe a static schema; of course, doing so will make it less
simple, compromising one of its current virtues.
The true danger is when liberty is nibbled away,
for expedients, and by parts. -- Edmund Burke