Blame alembic/versions/27a79ff0fb41_add_modify_project_acl.py

Matt Prahl 30f8b1
"""Add modify_project ACL
Matt Prahl 30f8b1
Matt Prahl 30f8b1
Revision ID: 27a79ff0fb41
Matt Prahl 30f8b1
Revises: d4d2c5aa8a0
Matt Prahl 30f8b1
Create Date: 2017-06-01 14:20:06.769321
Matt Prahl 30f8b1
Matt Prahl 30f8b1
"""
Matt Prahl 30f8b1
Matt Prahl 30f8b1
# revision identifiers, used by Alembic.
Matt Prahl 30f8b1
revision = '27a79ff0fb41'
Matt Prahl 30f8b1
down_revision = '5179e99d35a5'
Matt Prahl 30f8b1
Matt Prahl 30f8b1
from alembic import op
Matt Prahl 30f8b1
import sqlalchemy as sa
Matt Prahl 30f8b1
Pierre-Yves Chibon 0e867d
try:
Pierre-Yves Chibon 0e867d
    from pagure.lib import model
Pierre-Yves Chibon 0e867d
except ImportError:
Pierre-Yves Chibon 0e867d
    import sys
Pierre-Yves Chibon 0e867d
    sys.path.insert(0, '.')
Pierre-Yves Chibon 0e867d
    from pagure.lib import model
Matt Prahl 30f8b1
Matt Prahl 30f8b1
Matt Prahl 30f8b1
def get_session():
Matt Prahl 30f8b1
    engine = op.get_bind()
Matt Prahl 30f8b1
    Session = sa.orm.scoped_session(sa.orm.sessionmaker())
Matt Prahl 30f8b1
    Session.configure(bind=engine)
Matt Prahl 30f8b1
    return Session()
Matt Prahl 30f8b1
Matt Prahl 30f8b1
Matt Prahl 30f8b1
def upgrade():
Matt Prahl 30f8b1
    session = get_session()
Matt Prahl 30f8b1
    modify_project_acl = model.ACL()
Matt Prahl 30f8b1
    modify_project_acl.name = 'modify_project'
Matt Prahl 30f8b1
    modify_project_acl.description = 'Modify a project'
Matt Prahl 30f8b1
    session.add(modify_project_acl)
Matt Prahl 30f8b1
    session.commit()
Matt Prahl 30f8b1
Matt Prahl 30f8b1
Matt Prahl 30f8b1
def downgrade():
Matt Prahl 30f8b1
    session = get_session()
Matt Prahl 30f8b1
    modify_project_acl = session.query(model.ACL).filter_by(
Matt Prahl 30f8b1
        name='modify_project').one()
Matt Prahl 30f8b1
    session.delete(modify_project_acl)
Matt Prahl 30f8b1
    session.commit()