Reputation: 120
I'm using Django and South. my model is:
class Msg(models.Model):
visible = models.BooleanField(default=True)
name = models.CharField(max_length=45)
and order of the field in the DB are:
When i add a new field, ie:
class Msg(models.Model):
visible = models.BooleanField(default=True)
default = models.BooleanField(default=True)
name = models.CharField(max_length=45)
and use:
python manage.py schemamigration myapp --auto
python manage.py migrate
the order of the field in the DB are:
how can i get something like the model ? - id - visible - default - name
thanks.
Best regards,
Upvotes: 0
Views: 349
Reputation: 32532
You would have to create a new table with the column order that you want, most likely. MySQL and PostgreSQL in particular don't reorder column names, and aren't changeable after table creation.
So, create a temp table in the order you want, dump all data, drop the old table, and rename the temp table to be the name you want.
However, unless it's for the sake of your own OCD, there's no real reason to do this.
Upvotes: 1