DB update for hardware version

pull/46/head
Konstantin Gründger 2016-02-20 11:26:09 +01:00 zatwierdzone przez Fabian P. Schmidt
rodzic 76362ddfbf
commit 33f456077d
1 zmienionych plików z 32 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,32 @@
"""hardware version hex to dec
Revision ID: 3a0765c9a2
Revises: 269ec1bcf99
Create Date: 2016-02-20 10:31:55.520815
"""
# revision identifiers, used by Alembic.
revision = '3a0765c9a2'
down_revision = '269ec1bcf99'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
conn = op.get_bind()
res = conn.execute("UPDATE aircraft_beacon "
"SET hardware_version = "
"16 * (hardware_version / 10) + (hardware_version % 10) "
"WHERE hardware_version IS NOT NULL")
def downgrade():
conn = op.get_bind()
res = conn.execute("UPDATE aircraft_beacon "
"SET hardware_version = "
"10 * (hardware_version / 16) + (hardware_version % 16) "
"WHERE hardware_version IS NOT NULL")