3237fc64b306_read_only_mode_in_projects.py 817 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. """Read Only mode in projects
  2. Revision ID: 3237fc64b306
  3. Revises: c34f4b09ef18
  4. Create Date: 2017-09-01 22:51:18.232541
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '3237fc64b306'
  8. down_revision = 'c34f4b09ef18'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. ''' Add a column to mark a project read only '''
  13. op.add_column(
  14. 'projects',
  15. sa.Column(
  16. 'read_only',
  17. sa.Boolean,
  18. default=True,
  19. nullable=True,
  20. )
  21. )
  22. op.execute(''' UPDATE projects SET read_only=False ''')
  23. op.alter_column(
  24. 'projects',
  25. 'read_only',
  26. nullable=False,
  27. existing_nullable=True
  28. )
  29. def downgrade():
  30. ''' Remove the read_only column from Projects '''
  31. op.drop_column('projects', 'read_only')