id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
393,South executes unnecessary SQL when adding a field,jacob@…,andrew,"South (appears to?) execute unnecessary SQL when adding new fields: it issues an `ALTER COLUMN ... TYPE` command that isn't needed.

This is under PostgreSQL/psycopg2.

To reproduce, start with this model:

{{{
class Person(models.Model):
    pass
}}}

Create an apply an initial migration, then add a field:

{{{
class Person(models.Model):
    name = models.CharField(max_length=200, default="""")
}}}

Create a migration for the `name` field, then run `migrate -v2`:

{{{
 - Soft matched migration 0002 to 0002_add_person_name_field.
Running migrations for people:
 - Migrating forwards to 0002_add_person_name_field.
 > people:0002_add_person_name_field
   = ALTER TABLE ""people_person"" ADD COLUMN ""name"" varchar(200) NOT NULL DEFAULT ''; []
   = ALTER TABLE ""people_person"" ALTER COLUMN ""name"" TYPE varchar(200), ALTER COLUMN ""name"" DROP DEFAULT, ALTER COLUMN ""name"" SET NOT NULL; []
}}}

Note the second `ALTER COLUMN ... TYPE` command.

I doubt that this is dangerous, but it is unnecessary, and on databases under load it could make migrations take longer (since `ALTER TYPE` requires an exclusive lock).",defect,reopened,minor,0.7,migrations,0.7-rc1,,,
