2

I'm attempting a migration from MySQL to PostgreSQL, and now I'm having trouble with concrete base classes. I have code similar to this:

class BaseKlass(models.Model):
    name = CharField(max_length = 64)

class SomeKlass(BaseKlass):
    value = IntegerField()

Whenever I create an instance of SomeKlass, I get an error like this:

IntegrityError: null value in column "baseklass_ptr_id" violates not-null constraint

I looked at the SQL being executed, and indeed the value for baseklass_ptr_id was null.

Any idea?

1
  • 1
    As you have discovered, Postgres is a lot more strict than MySQL. +1 because it looks like you answered your own question. Commented Dec 29, 2012 at 23:52

1 Answer 1

2

Setting an owner for the id sequence solved the problem:

ALTER SEQUENCE myapp_baseklass_id_seq OWNED BY myapp_baseklass.id;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.