#25002: Postgresql migration fails when changing a CharField to a TimeField
-------------------------------------+-------------------------------------
     Reporter:  dirkcuys             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  migrations           |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by dirkcuys:

Old description:

> The code from the migration is as follows:
>
> {{{#!python
> 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;
> }}}

New description:

 The code from the migration is as follows:

 {{{#!python
 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;
 }}}

 I don't have code with the problem isolated, but this project shows the
 problem when configured to use postgres. http://github.com/p2pu/knight-
 app/.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25002#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.46d9d45a2dd183ef957c013bb3df98ab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to