1
0

e3cc5aedb8bb_add_date_updated_to_pr_flags.py 948 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """Add date_updated to PR flags
  2. Revision ID: e3cc5aedb8bb
  3. Revises: f16ab75e4d32
  4. Create Date: 2018-11-14 11:45:48.519035
  5. """
  6. import datetime
  7. from alembic import op
  8. import sqlalchemy as sa
  9. # revision identifiers, used by Alembic.
  10. revision = 'e3cc5aedb8bb'
  11. down_revision = 'f16ab75e4d32'
  12. def upgrade():
  13. """ Add date_updated column to pull_request_flags table """
  14. op.add_column(
  15. 'pull_request_flags',
  16. sa.Column(
  17. 'date_updated',
  18. sa.DateTime,
  19. nullable=True,
  20. default=datetime.datetime.utcnow,
  21. )
  22. )
  23. op.execute('UPDATE pull_request_flags SET date_updated=date_created')
  24. op.alter_column(
  25. 'pull_request_flags', 'date_updated', existing_type=sa.DateTime,
  26. nullable=False, existing_nullable=True)
  27. def downgrade():
  28. """ Drop the date_updated column from the pull_request_flags table """
  29. op.drop_column('pull_request_flags', 'date_updated')