Ticket #582 (new defect)

Opened 5 years ago

Last modified 5 years ago

alter_column error in postgres when changing from a textfield

Reported by: mark.baker@… Owned by: andrew
Priority: major Milestone:
Component: migrations Version: 0.7.1
Keywords: postgres Cc:


Altering from a textfield to a boolean in postgres:

#db.alter_column('table_name', 'column_name', self.gf('django.db.models.fields.BooleanField?')(blank=True))

Comes up with the error:

django.db.utils.DatabaseError?: column "column_name" cannot be cast to type "pg_catalog.bool"

Same thing happens when changing a textfield to an integer too.

Had to use:
db.delete_column('table_name', 'column_name')
db.add_column('table_name', 'column_name', self.gf('django.db.models.fields.BooleanField?')(default=False, blank=True))
instead which worked.

Change History

comment:1 Changed 5 years ago by rlafuente

Thanks for this workaround, this has been a headache for me using Postgres.
This solution ought to be posted in bug #484 while the fix for Postgres is not implemented.

Note: See TracTickets for help on using tickets.