| Total Complexity | 2 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """add_sortlabel |
||
| 2 | |||
| 3 | Revision ID: 6dfc3e2324aa |
||
| 4 | Revises: b04fd493106b |
||
| 5 | Create Date: 2017-07-04 13:53:00.064535 |
||
| 6 | |||
| 7 | """ |
||
| 8 | import sqlalchemy as sa |
||
| 9 | from alembic import op |
||
| 10 | from sqlalchemy.orm import Session |
||
| 11 | |||
| 12 | # revision identifiers, used by Alembic. |
||
| 13 | revision = "6dfc3e2324aa" |
||
| 14 | down_revision = "b04fd493106b" |
||
| 15 | |||
| 16 | |||
| 17 | labeltype_table = sa.Table( |
||
| 18 | "labeltype", |
||
| 19 | sa.MetaData(), |
||
| 20 | sa.Column("name", sa.String), |
||
| 21 | sa.Column("description", sa.String), |
||
| 22 | ) |
||
| 23 | |||
| 24 | |||
| 25 | def upgrade(): |
||
| 26 | |||
| 27 | op.bulk_insert( |
||
| 28 | labeltype_table, [{"name": "sortLabel", "description": "A sorting label."}] |
||
| 29 | ) |
||
| 30 | |||
| 31 | |||
| 32 | def downgrade(): |
||
| 33 | connection = op.get_bind() |
||
| 34 | session = Session(bind=connection) |
||
| 35 | connection.execute( |
||
| 36 | labeltype_table.delete().where(labeltype_table.c.name == "sortLabel") |
||
| 37 | ) |
||
| 38 | session.flush() |
||
| 39 |