Files
notifications-api/migrations/versions/0194_ft_billing_created_at.py
Katie Smith c6c118fea1 Update created_at column of ft_billing to be non-nullable
`created_at` was added previously and made nullable temporarily. This
commit now populates the column, ensures that it will always have a
value, and makes `created_at` non-nullable.
2018-05-23 11:09:13 +01:00

24 lines
590 B
Python

"""
Revision ID: 0194_ft_billing_created_at
Revises: 0193_add_ft_billing_timestamps
Create Date: 2018-05-22 14:34:27.852096
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '0194_ft_billing_created_at'
down_revision = '0193_add_ft_billing_timestamps'
def upgrade():
op.execute("UPDATE ft_billing SET created_at = NOW()")
op.alter_column('ft_billing', 'created_at', nullable=False)
def downgrade():
op.alter_column('ft_billing', 'created_at', nullable=True)
op.execute("UPDATE ft_billing SET created_at = null")