-
Vladimir Mencl authored
Add workaround for an issue with running South Migrations on PostgreSQL. Migration 0022_auto__chg_field_institutiondetails_number_id__del_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: * Workaround via db.execute: http://codeinthehole.com/writing/altering-postgres-table-columns-with-south/ * USING syntax to convert integers: http://stackoverflow.com/questions/13170570/change-type-of-varchar-field-to-integer-cannot-be-cast-automatically-to-type-i
9a2924d5