8a5d68f74beb_add_date_modified_for_project.py 848 B

123456789101112131415161718192021222324252627282930313233343536
  1. """Add date_modified for project
  2. Revision ID: 8a5d68f74beb
  3. Revises: 27a79ff0fb41
  4. Create Date: 2017-07-18 19:28:09.566997
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '8a5d68f74beb'
  10. down_revision = '27a79ff0fb41'
  11. def upgrade():
  12. ''' Add the column date_modified to the table projects.
  13. '''
  14. op.add_column(
  15. 'projects',
  16. sa.Column('date_modified', sa.DateTime, nullable=True,
  17. default=sa.func.now())
  18. )
  19. op.execute("UPDATE projects SET date_modified=date_created;")
  20. op.alter_column(
  21. 'projects',
  22. column_name='date_modified',
  23. nullable=False,
  24. existing_nullable=True)
  25. def downgrade():
  26. ''' Remove the column date_modified from the table projects.
  27. '''
  28. op.drop_column('projects', 'date_modified')