Opened 9 years ago
Last modified 7 years ago
#25002 closed Bug
Postgresql migration fails when changing a CharField to a TimeField — at Initial Version
Reported by: | Dirk Uys | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | migrations |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The code from the migration is as follows:
migrations.AlterField( model_name='studygroup', name='time', field=models.TimeField(), ),
The field used to be a models.CharField()
The error follows:
django.db.utils.ProgrammingError: column "time" cannot be cast automatically to type time without time zone HINT: Specify a USING expression to perform the conversion
I can manually fix this using SQL:
ALTER TABLE "studygroups_studygroup" ALTER COLUMN "time" TYPE time USING "time"::time;
Note:
See TracTickets
for help on using tickets.