grnet / djnro

DjNRO hits the decks of eduroam database management
http://djnro.grnet.gr/
Other
10 stars 21 forks source link

South migrations: add PostgreSQL issue workaround #4

Closed vladimir-mencl-eresearch closed 8 years ago

vladimir-mencl-eresearch commented 8 years ago

Add workaround for an issue with running South Migrations on PostgreSQL.

Migration 0022_autochg_field_institutiondetails_number_iddel_field_instrealmmon_i.py breaks on PostgreSQL with:

ERROR:  column "realm_id" cannot be cast automatically to type integer
HINT:  Specify a USING expression to perform the conversion.
STATEMENT:  ALTER TABLE "edumanage_instrealmmon" ALTER COLUMN "realm_id" TYPE integer,
        ALTER COLUMN "realm_id" SET NOT NULL, ALTER COLUMN "realm_id" DROP DEFAULT;

This is a known problem: http://south.aeracode.org/ticket/484 (PostgreSQL will not automatically convert and conversion must be provided with the USING clause) Workaround: For PostgreSQL invoke a direct SQL statement amended with a USING clause to do the converion explicitly.

Rely on db._get_connection().vendor to determine if we are running on PostgreSQL.

Credits: