mozilla / django-badger

django-badger is a reusable Django app for creating and awarding badges. See also badges.mozilla.org
https://github.com/mozilla/django-badger
BSD 3-Clause "New" or "Revised" License
117 stars 61 forks source link

Error in migration: badger:0004_auto__add_nomination #168

Open ToxicWar opened 11 years ago

ToxicWar commented 11 years ago

Error in postgreSQL 9.1 FATAL ERROR - The following SQL query failed: CREATE TABLE "badger_nomination" ("id" serial NOT NULL PRIMARY KEY, "badge_id" integer NOT NULL, "nominee_id" integer NOT NULL, "accepted" boolean NOT NULL, "creator_id" integer NULL, "approver_id" integer NULL, "award_id" integer NULL, "created" timestamp with time zone NOT NULL, "modified" timestamp with time zone NOT NULL); The error was: current transaction is aborted, commands ignored until end of transaction block

lmorchard commented 11 years ago

Hmm, I've never tried django-badger with postgresql, so I probably won't have much useful input here.

askvictor commented 11 years ago

I've experienced this also; the noted hack to see if the table exists seems to be the cause of this. I bypassed the code which uses the _table_exists() function and it works fine... so after finding https://gist.github.com/rctay/527113#comment-337110 I tried:

from django.db import connection
...
def _table_exists(self, name):
    """Determine whether the table exists."""
    return name in connection.introspection.table_names()

Which works nicely in Postgres, but untested on MySQL

sunshineo commented 11 years ago

My workaround is this:

Manually run the query on postgresql

CREATE TABLE "badger_nomination" ("id" serial NOT NULL PRIMARY KEY, "badge_id" integer NOT NULL, "nominee_id" integer NOT NULL, "accepted" boolean NOT NULL, "creator_id" integer NULL, "approver_id" integer NULL, "award_id" integer NULL, "created" timestamp with time zone NOT NULL, "modified" timestamp with time zone NOT NULL);

manage.py migrate badger 0004_auto__add_nomination --fake

python manage.py migrate badger