@@ -0,0 +1,1467 @@
+from __future__ import print_function, unicode_literals%0A%22%22%22Add new permission to administrator%0A%0ARevision ID: 498a6d3a1e0f%0ARevises: 40cdc63a949a%0ACreate Date: 2015-07-19 23:32:37.230646%0A%0A%22%22%22%0A%0A# revision identifiers, used by Alembic.%0Arevision = '498a6d3a1e0f'%0Adown_revision = u'40cdc63a949a'%0A%0Aimport datetime%0A%0Afrom alembic import op%0Aimport sqlalchemy as sa%0Aimport sqlalchemy.sql as sql%0A%0Ametadata = sa.MetaData()%0Arole = sa.Table('Role', metadata,%0A    sa.Column('id', sa.Integer()),%0A    sa.Column('name', sa.Unicode(20)),%0A)%0A%0Arole_permission = sa.Table('RolePermission', metadata,%0A    sa.Column('id', sa.Integer()),%0A    sa.Column('role_id', sa.Integer()),%0A    sa.Column('permission_type', sa.String(255)),%0A    sa.Column('permanent_id', sa.String(255)),%0A    sa.Column('date', sa.DateTime),%0A)%0A%0Adef upgrade():%0A    s = sql.select(%5B role.c.id %5D, role.c.name == 'administrator')%0A    results = op.get_bind().execute(s)%0A    if results:%0A        admin_role_id = list(results)%5B0%5D%5B0%5D%0A        s = sql.select(%5B role_permission.c.id %5D, sql.and_(role_permission.c.role_id == admin_role_id, role_permission.c.permission_type == 'access_all_labs'))%0A        if len(list(op.get_bind().execute(s))) == 0:%0A            new_role_permission = role_permission.insert().values(role_id=admin_role_id, permission_type='access_all_labs', date=datetime.datetime.now(), permanent_id=%22administrator_role::access_all_labs%22)%0A            op.get_bind().execute(new_role_permission)%0A%0A%0Adef downgrade():%0A    pass%0A

Add rolepermission automatically