"Fossies" - the Fresh Open Source Software Archive

Member "indico-2.2.5/indico/migrations/versions/20170905_1445_f1eee7b4880a_add_event_roles_table.py" (6 Dec 2019, 1423 Bytes) of package /linux/www/indico-2.2.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "20170905_1445_f1eee7b4880a_add_event_roles_table.py" see the Fossies "Dox" file reference documentation.

    1 """Add event roles table
    2 
    3 Revision ID: f1eee7b4880a
    4 Revises:
    5 Create Date: 2017-09-05 14:45:28.673606
    6 """
    7 
    8 import sqlalchemy as sa
    9 from alembic import op
   10 
   11 
   12 # revision identifiers, used by Alembic.
   13 revision = 'f1eee7b4880a'
   14 down_revision = None
   15 branch_labels = None
   16 depends_on = None
   17 
   18 
   19 def upgrade():
   20     op.create_table(
   21         'roles',
   22         sa.Column('id', sa.Integer(), nullable=False),
   23         sa.Column('event_id', sa.Integer(), nullable=False, index=True),
   24         sa.Column('name', sa.String(), nullable=False),
   25         sa.Column('code', sa.String(), nullable=False),
   26         sa.Column('color', sa.String(), nullable=False),
   27         sa.Index(None, 'event_id', 'code', unique=True),
   28         sa.CheckConstraint('code = upper(code)', name='uppercase_code'),
   29         sa.ForeignKeyConstraint(['event_id'], ['events.events.id']),
   30         sa.PrimaryKeyConstraint('id'),
   31         schema='events'
   32     )
   33     op.create_table(
   34         'role_members',
   35         sa.Column('role_id', sa.Integer(), nullable=False, index=True),
   36         sa.Column('user_id', sa.Integer(), nullable=False, index=True),
   37         sa.ForeignKeyConstraint(['role_id'], ['events.roles.id']),
   38         sa.ForeignKeyConstraint(['user_id'], ['users.users.id']),
   39         sa.PrimaryKeyConstraint('role_id', 'user_id'),
   40         schema='events'
   41     )
   42 
   43 
   44 def downgrade():
   45     op.drop_table('role_members', schema='events')
   46     op.drop_table('roles', schema='events')