Ticket #582 (new defect)

Opened 4 years ago

Last modified 4 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:

Description

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 4 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.