Adding timezone to TIMESTAMP (Postgres) in Alembic

1,272 views
Skip to first unread message

alchemy1

unread,
Aug 26, 2014, 8:42:50 AM8/26/14
to sqlal...@googlegroups.com
I added a Postgres TIMESTAMP column and ran a migration, then realized I wanted to do TIMESTAMP(timezone=True) so I updated my models then ran another migration, but the migration files had a 'pass' in the upgrade/downgrade functions rather than doing anything. I had to revert to the migration before I added the TIMESTAMP(without time zone) columns then re-run a migration to get it to work. Just wanted to see if it was me doing something wrong or if adding a timezone to an existing TIMESTAMP isn't (yet) supported by Alembic.

Michael Bayer

unread,
Aug 26, 2014, 10:30:21 AM8/26/14
to sqlal...@googlegroups.com

On Aug 26, 2014, at 8:42 AM, alchemy1 <veeruk...@hotmail.com> wrote:

> I added a Postgres TIMESTAMP column and ran a migration, then realized I wanted to do TIMESTAMP(timezone=True) so I updated my models then ran another migration, but the migration files had a 'pass' in the upgrade/downgrade functions rather than doing anything.

autogenerate can only detect a limited set of changes, see the guidelines at http://alembic.readthedocs.org/en/latest/tutorial.html#auto-generating-migrations for a general idea of what works “out of the box (tables, columns, indexes)” and what doesn’t (everything else).


> I had to revert to the migration before I added the TIMESTAMP(without time zone) columns then re-run a migration to get it to work. Just wanted to see if it was me doing something wrong or if adding a timezone to an existing TIMESTAMP isn't (yet) supported by Alembic.

when autogenerate doesn’t do what is needed, you write the migration manually. autogenerate is just a convenience feature on top of things to assist in writing scripts.
Reply all
Reply to author
Forward
0 new messages