12fd0621c50b_create_tables.upgrade()   B
last analyzed

Complexity

Conditions 1

Size

Total Lines 59
Code Lines 52

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 52
nop 0
dl 0
loc 59
rs 8.5709
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
"""create tables
2
3
Revision ID: 12fd0621c50b
4
Revises: 
5
Create Date: 2022-11-24 14:18:50.903819
6
7
"""
8
from alembic import op
9
import sqlalchemy as sa
10
11
12
# revision identifiers, used by Alembic.
13
revision = "12fd0621c50b"
14
down_revision = None
15
branch_labels = None
16
depends_on = None
17
18
19
def upgrade() -> None:
20
    op.create_table(
21
        'schools',
22
        sa.Column('school', sa.TEXT, unique=True, nullable=False),
23
        sa.Column('region', sa.TEXT, nullable=False),
24
        sa.Column('color', sa.INTEGER, nullable=False),
25
        sa.Column('id', sa.BIGINT, nullable=False),
26
        sa.Column('added_by', sa.TEXT, nullable=False),
27
        sa.Column('added_by_id', sa.BIGINT, nullable=False),
28
        sa.PrimaryKeyConstraint('school')
29
    )
30
    op.create_table(
31
        'bot_admins',
32
        sa.Column('id', sa.BIGINT, unique=True, nullable=False),
33
        sa.Column('name', sa.TEXT, nullable=False),
34
        sa.PrimaryKeyConstraint('user_id')
35
    )
36
    op.create_table(
37
        'admin_channels',
38
        sa.Column('id', sa.BIGINT, unique=True, nullable=False),
39
        sa.Column('guild_id', sa.BIGINT, nullable=False),
40
        sa.Column('log', sa.Boolean, default=False),
41
        sa.PrimaryKeyConstraint('id')
42
    )
43
    op.create_table(
44
        'regions',
45
        sa.Column('name', sa.TEXT, unique=True, nullable=False),
46
        sa.Column('id', sa.BIGINT, nullable=False),
47
        sa.PrimaryKeyConstraint('name')
48
    )
49
    op.create_table(
50
        'errors',
51
        sa.Column('id', sa.BIGINT, unique=True, nullable=False),
52
        sa.Column('command', sa.TEXT, nullable=False),
53
        sa.Column('message', sa.TEXT, nullable=False),
54
        sa.Column('error', sa.TEXT, nullable=False),
55
        sa.Column('time', sa.TIMESTAMP, nullable=False),
56
        sa.Column('ack', sa.Boolean, nullable=False, default=False),
57
        sa.PrimaryKeyConstraint('id')
58
    )
59
    op.create_table(
60
        'keys',
61
        sa.Column('key', sa.TEXT, unique=True, nullable=False),
62
        sa.Column('value', sa.TEXT, nullable=False),
63
    )
64
    op.create_table(
65
        'messages',
66
        sa.Column('name', sa.TEXT, unique=True, nullable=False),
67
        sa.Column('message', sa.TEXT, nullable=False),
68
        sa.PrimaryKeyConstraint('name')
69
    )
70
    op.create_table(
71
        'reports',
72
        sa.Column('id', sa.BIGINT, unique=True, nullable=False),
73
        sa.Column('name', sa.TEXT, nullable=False),
74
        sa.Column('name_id', sa.BIGINT, nullable=False),
75
        sa.Column('message', sa.TEXT, nullable=False),
76
        sa.Column('time', sa.TIMESTAMP, nullable=False),
77
        sa.PrimaryKeyConstraint('id')
78
    )
79
80
def downgrade() -> None:
81
    op.drop_table('schools')
82
    op.drop_table('bot_admins')
83
    op.drop_table('admin_channels')
84
    op.drop_table('regions')
85
    op.drop_table('errors')
86
    op.drop_table('keys')
87
    op.drop_table('messages')
88
    op.drop_table('reports')
89