Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango 1.4 TimeField migration fails on PostgreSQL
    primarykey
    data
    text
    <p>I edited two fields on a model and changed them from <code>IntegerField</code>s to <code>TimeField</code>s:</p> <pre><code>class Model(models.Model): start_time = models.TimeField() end_time = models.TimeField() </code></pre> <p>I'm using these two fields to save a naive time, which is not related to any geographical notion of time, and thus has no real 'time zone' (think something similar to race times). My local database is PostgreSQL.</p> <p>However, the south migration generated from this change fails with the following error:</p> <pre><code>&gt; main:0005_auto__chg_field_model_start_time__chg_field_model_end_time FATAL ERROR - The following SQL query failed: ALTER TABLE "main_model" ALTER COLUMN "start_time" TYPE time, ALTER COLUMN "start_time" SET NOT NULL, ALTER COLUMN "start_time" DROP DEFAULT; ... File ".../lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute return self.cursor.execute(query, args) django.db.utils.DatabaseError: column "start_time" cannot be cast to type time without time zone </code></pre> <p>The failed migration has this:</p> <pre><code>class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'Model.start_time' db.alter_column('main_model', 'start_time', self.gf('django.db.models.fields.TimeField')()) # Changing field 'Model.end_time' db.alter_column('main_model', 'end_time', self.gf('django.db.models.fields.TimeField')()) </code></pre> <p>Any idea on how to make postgres happy about this migration?</p> <p>P.S. I'm in the midst of development, so I really don't care about any data migrations. You may assume the DB is empty.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload