Opened 7 years ago

Closed 7 years ago

#28633 closed Uncategorized (duplicate)

Migrate BooleanField to IntegerField

Reported by: Dmitriy Sintsov Owned by: nobody
Component: Migrations Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It should be quite trivial and obvious that False is replaced to 0, while True to 1. However SQLMIGRATE generated code

ALTER TABLE "isp_user_profile" ALTER COLUMN "is_filled" TYPE integer;

produces the following PostgreSQL error:

django.db.utils.ProgrammingError: column "is_filled" cannot be cast automatically to type integer
HINT:  You might need to specify "USING is_filled::integer".

Why USING statement is not generated automatically?

The workaround is to create RunSQL migration manually, but it would be much more convenient to have correct SQL code generated automatically.

There is no data loss in direct conversion from boolean to integer.

Change History (1)

comment:1 by Simon Charette, 7 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #25002 which is fixed in Django 1.9.

Note: See TracTickets for help on using tickets.
Back to Top