Passed
Push — develop ( 297c7c...ca43ab )
by Bastien
03:02
created

8957d4adbc77_rename_manager_group   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 32
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A downgrade() 0 9 1
A upgrade() 0 9 1
1
"""rename_manager_group
2
3
Revision ID: 8957d4adbc77
4
Revises: c223cce1a413
5
Create Date: 2018-09-20 10:56:29.173246
6
7
"""
8
9
# revision identifiers, used by Alembic.
10
from datetime import datetime
11
12
revision = '8957d4adbc77'
13
down_revision = 'c223cce1a413'
14
15
from alembic import op
16
import sqlalchemy as sa
17
18
group = sa.Table(
19
    'groups',
20
    sa.MetaData(),
21
    sa.Column('group_id', sa.Integer, sa.Sequence('seq__groups__group_id'),
22
              autoincrement=True, primary_key=True),
23
    sa.Column('group_name', sa.Unicode(16), unique=True, nullable=False),
24
    sa.Column('display_name', sa.Unicode(255)),
25
    sa.Column('created', sa.DateTime, default=datetime.utcnow),
26
)
27
28
29
def upgrade():
30
    connection = op.get_bind()
31
    connection.execute(
32
        group.update()
33
        .where(
34
            group.c.group_name == 'managers'
35
        ).values(
36
            group_name='trusted-users',
37
            display_name='Trusted Users',
38
        )
39
    )
40
41
42
def downgrade():
43
    connection = op.get_bind()
44
    connection.execute(
45
        group.update()
46
        .where(
47
            group.c.group_name == 'trusted-users'
48
        ).values(
49
            group_name='managers',
50
            display_name='Global Managers',
51
        )
52
    )
53
    # ### end Alembic commands ###
54