Last active
August 29, 2015 14:17
-
-
Save julianwachholz/96634b32ff823ee5e75e to your computer and use it in GitHub Desktop.
Django migration from `time without time zone` to `timestamp with time zone`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('offers', '0001_initial'), | |
] | |
operations = [ | |
migrations.RunSQL( | |
sql=""" | |
ALTER TABLE offers_offer | |
ALTER COLUMN time TYPE timestamp with time zone | |
USING to_timestamp('2014-04-01 ' || time, 'YYYY-MM-DD HH24:MI:SS'); | |
""", | |
reverse_sql=""" | |
ALTER TABLE offers_offer | |
ALTER COLUMN time TYPE time without time zone; | |
""", | |
state_operations=[migrations.AlterField( | |
model_name='offer', | |
name='time', | |
field=models.DateTimeField(verbose_name='Offer time'), | |
preserve_default=True | |
)] | |
), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment