Ticket #1058 (closed defect: worksforme)
PostreSQL issues with alter commands
|Reported by:||segnalazioni@…||Owned by:||andrew|
Applying migrations that involves alter_column on foreign keys or alter_tables fail.
db.alter_column('categories_category', 'parent_id', self.gf('mptt.fields.TreeForeignKey')(null=True, to=orm['categories.Category']))
from django-categories 1.0.3 fails with
FATAL ERROR - The following SQL query failed: ALTER TABLE "categories_category" ADD CONSTRAINT "parent_id_refs_id_26f7e8d2e85f846b" FOREIGN KEY ("parent_id") REFERENCES "categories_category" ("id") DEFERRABLE INITIALLY DEFERRED; The error was: constraint "parent_id_refs_id_26f7e8d2e85f846b" for relation "categories_category" already exists
It looks like _fill_constraint_cache() method in DatabaseOperations?() fill the cache with both the foreign key and the related key, so that _find_foreign_constraints cannot find the involved constraint.
Renaming table also fails
from django-cms 2.2 (migration is actually in application plugins.text.migrations) fails with
FATAL ERROR - The following SQL query failed: ALTER TABLE "text_text_id_seq" RENAME TO "cmsplugin_text_id_seq"; The error was: relation "text_text_id_seq" does not exist
I tried patch at #1057 but this doesn't solve the issue.
Tried with both PostgreSQL 8.4 and 9.1, in different virtualenvs and different machines
Reverting to South 0.7.3 solves the issue