27a79ff0fb41_add_modify_project_acl.py 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """Add modify_project ACL
  2. Revision ID: 27a79ff0fb41
  3. Revises: d4d2c5aa8a0
  4. Create Date: 2017-06-01 14:20:06.769321
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '27a79ff0fb41'
  8. down_revision = '5179e99d35a5'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. try:
  12. from pagure.lib import model
  13. except ImportError:
  14. import sys
  15. sys.path.insert(0, '.')
  16. from pagure.lib import model
  17. def get_session():
  18. engine = op.get_bind()
  19. Session = sa.orm.scoped_session(sa.orm.sessionmaker())
  20. Session.configure(bind=engine)
  21. return Session()
  22. def upgrade():
  23. session = get_session()
  24. modify_project_acl = model.ACL()
  25. modify_project_acl.name = 'modify_project'
  26. modify_project_acl.description = 'Modify a project'
  27. session.add(modify_project_acl)
  28. session.commit()
  29. def downgrade():
  30. session = get_session()
  31. modify_project_acl = session.query(model.ACL).filter_by(
  32. name='modify_project').one()
  33. session.delete(modify_project_acl)
  34. session.commit()