Django migration having no effect, on postgres table

477 views Asked by At

When I was initially laying out my tables I for what ever reason used PositiveIntegerField for a price. Now I've changed it to DecimalField which makes more sense.

The migration worked locally (sqlite) and appears to have succeeded on my dev server. However, the migration had no effect on my postgres dev server.

Here's the output from the migration command.

DJANOG_SETTINGS_MODULE=runner.dev_settings ./manage.py migrate
Operations to perform:
  Apply all migrations: userprofiles, sessions, admin, sites, auth, contenttypes, inventory
Running migrations:
  Applying inventory.0004_auto_20150613_1446... OK

After migration here's the schema in pgsql.

                                     Table "public.inventory_baseitem"
     Column      |          Type          |                            Modifiers                            
-----------------+------------------------+-----------------------------------------------------------------
 id              | integer                | not null default nextval('inventory_baseitem_id_seq'::regclass)
 title           | character varying(100) | not null
 price           | integer                | not null
 units           | integer                | not null
 weight_lbs      | integer                | not null
 weight_ozs      | integer                | not null
 content_type_id | integer                | not null
...

As you can see the price column's type is still integer. Frustratingly if I re-run the migration django says that there are no migrations to apply.

While this is not a production environment, so if worst comes to worst I can just do a manual alter table. Doing so defeats the purpose of having django migrations.

Per the feedback, my django version is 1.7. My migration is as follows:

class Migration(migrations.Migration):

    dependencies = [
        ('inventory', '0003_auto_20150613_1439'),
    ]

    operations = [
        migrations.AlterField(
            model_name='baseitem',
            name='price',
            field=models.DecimalField(default=0, max_digits=20, decimal_places=2),
        ),
    ]

I will try upgrading my django version is that doesn't come with too many breaking changes.

0

There are 0 answers