"""add date to static pages

Revision ID: 4d46f8aeed5
Revises: 39f25296cd6
Create Date: 2017-06-30 11:38:03.428087

"""

# revision identifiers, used by Alembic.
revision = '4d46f8aeed5'
down_revision = '39f25296cd6'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('page', sa.Column('date', sa.DateTime(timezone=True), server_default=sa.text(u'now()'), nullable=False))
    op.create_index(op.f('ix_page_date'), 'page', ['date'], unique=False)
    op.execute('UPDATE "page" set date = created_at')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_page_date'), table_name='page')
    op.drop_column('page', 'date')
    ### end Alembic commands ###
