This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/migrations/versions/3eb50297c365_add_hash.py

43 lines
1.1 KiB
Python
Raw Normal View History

2020-12-18 15:45:08 +00:00
"""empty message
Revision ID: 3eb50297c365
Revises: 378b6b147b46
Create Date: 2020-12-18 16:26:15.453694
"""
from alembic import context
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
import citext
import teal
# revision identifiers, used by Alembic.
revision = '3eb50297c365'
down_revision = '378b6b147b46'
branch_labels = None
depends_on = None
def get_inv():
INV = context.get_x_argument(as_dictionary=True).get('inventory')
if not INV:
raise ValueError("Inventory value is not specified")
return INV
def upgrade():
# Report Hash table
op.create_table('report_hash',
sa.Column('id', sa.BigInteger(), nullable=False),
sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'),
nullable=False, comment='When Devicehub created this.'),
sa.Column('hash', citext.CIText(), nullable=False),
sa.PrimaryKeyConstraint('id'),
schema=f'{get_inv()}'
)
def downgrade():
op.drop_table('report_hash', schema=f'{get_inv()}')