184f1bbcb916_language_und.upgrade()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 0
1
"""language_und
2
3
Revision ID: 184f1bbcb916
4
Revises: 6dfc3e2324aa
5
Create Date: 2017-07-25 16:38:39.439673
6
7
"""
8
import sqlalchemy as sa
9
from alembic import op
10
from sqlalchemy.orm import Session
11
from sqlalchemy.sql import column
12
from sqlalchemy.sql import table
13
14
# revision identifiers, used by Alembic.
15
revision = "184f1bbcb916"
16
down_revision = "6dfc3e2324aa"
17
18
19
language_table = table("language", column("id", sa.String), column("name", sa.String))
20
21
22
def upgrade():
23
24
    op.bulk_insert(language_table, [{"id": "und", "name": "Undetermined"}])
25
26
27
def downgrade():
28
    connection = op.get_bind()
29
    session = Session(bind=connection)
30
    connection.execute(language_table.delete().where(language_table.c.id == "und"))
31
    session.flush()
32