pyelephant/alembic/versions/ac2bd309d20c_add_created_at_to_tasks.py

35 lines
786 B
Python
Raw Permalink Normal View History

2020-05-20 12:56:18 +10:00
"""add created_at to tasks
Revision ID: ac2bd309d20c
Revises: 40867bd0dcc8
Create Date: 2020-05-20 12:36:53.685254
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ac2bd309d20c'
down_revision = '40867bd0dcc8'
branch_labels = None
depends_on = None
def upgrade():
# Requires batching for non-constant default under SQLite.
with op.batch_alter_table('tasks', recreate='always') as batch:
batch.add_column(
sa.Column(
'created_at',
sa.DateTime,
server_default=sa.func.current_timestamp(),
nullable=False
)
)
def downgrade():
with op.batch_alter_table('tasks') as tasks:
tasks.drop_column('created_at')