Blame alembic/versions/e3cc5aedb8bb_add_date_updated_to_pr_flags.py
|
Pierre-Yves Chibon |
669c00 |
"""Add date_updated to PR flags
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
Revision ID: e3cc5aedb8bb
|
|
Pierre-Yves Chibon |
669c00 |
Revises: f16ab75e4d32
|
|
Pierre-Yves Chibon |
669c00 |
Create Date: 2018-11-14 11:45:48.519035
|
|
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 |
# revision identifiers, used by Alembic.
|
|
Pierre-Yves Chibon |
669c00 |
revision = 'e3cc5aedb8bb'
|
|
Pierre-Yves Chibon |
669c00 |
down_revision = 'f16ab75e4d32'
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
|
|
Pierre-Yves Chibon |
669c00 |
def upgrade():
|
|
Pierre-Yves Chibon |
669c00 |
""" Add date_updated column to pull_request_flags table """
|
|
Pierre-Yves Chibon |
669c00 |
op.add_column(
|
|
Pierre-Yves Chibon |
669c00 |
'pull_request_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 pull_request_flags SET date_updated=date_created')
|
|
Pierre-Yves Chibon |
669c00 |
op.alter_column(
|
|
Pierre-Yves Chibon |
641bec |
'pull_request_flags', 'date_updated', existing_type=sa.DateTime,
|
|
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 pull_request_flags table """
|
|
Pierre-Yves Chibon |
669c00 |
op.drop_column('pull_request_flags', 'date_updated')
|