9cb4580e269a_add_date_updated_to_commit_flags.py 917 B

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