Blame alembic/versions/9cb4580e269a_add_date_updated_to_commit_flags.py
|
Pierre-Yves Chibon |
669c00 |
"""Add date_updated to commit flags
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
Revision ID: 9cb4580e269a
|
|
Pierre-Yves Chibon |
669c00 |
Revises: e3cc5aedb8bb
|
|
Pierre-Yves Chibon |
669c00 |
Create Date: 2018-11-14 11:48:47.436459
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
"""
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
import datetime
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
from alembic import op
|
|
Pierre-Yves Chibon |
669c00 |
import sqlalchemy as sa
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
# revision identifiers, used by Alembic.
|
|
Pierre-Yves Chibon |
669c00 |
revision = '9cb4580e269a'
|
|
Pierre-Yves Chibon |
669c00 |
down_revision = 'e3cc5aedb8bb'
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
def upgrade():
|
|
Pierre-Yves Chibon |
669c00 |
""" Add date_updated column to commit_flags table """
|
|
Pierre-Yves Chibon |
669c00 |
op.add_column(
|
|
Pierre-Yves Chibon |
669c00 |
'commit_flags',
|
|
Pierre-Yves Chibon |
669c00 |
sa.Column(
|
|
Pierre-Yves Chibon |
669c00 |
'date_updated',
|
|
Pierre-Yves Chibon |
669c00 |
sa.DateTime,
|
|
Pierre-Yves Chibon |
669c00 |
nullable=True,
|
|
Pierre-Yves Chibon |
669c00 |
default=datetime.datetime.utcnow,
|
|
Pierre-Yves Chibon |
669c00 |
)
|
|
Pierre-Yves Chibon |
669c00 |
)
|
|
Pierre-Yves Chibon |
669c00 |
op.execute('UPDATE commit_flags SET date_updated=date_created')
|
|
Pierre-Yves Chibon |
669c00 |
op.alter_column(
|
|
Pierre-Yves Chibon |
669c00 |
'commit_flags', 'date_updated',
|
|
Pierre-Yves Chibon |
669c00 |
nullable=False, existing_nullable=True)
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
def downgrade():
|
|
Pierre-Yves Chibon |
669c00 |
""" Drop the date_updated column from the commit_flags table """
|
|
Pierre-Yves Chibon |
669c00 |
op.drop_column('commit_flags', 'date_updated')
|