This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/migrations/versions/faf752bd2e0a_add_user_metadata_fields.py

57 lines
1.9 KiB
Python
Raw Normal View History

2019-11-12 16:09:47 +00:00
"""Add user metadata fields
Revision ID: faf752bd2e0a
Revises: 6c7014e84a5e
Create Date: 2016-11-14 17:29:03.984665
"""
# revision identifiers, used by Alembic.
revision = 'faf752bd2e0a'
down_revision = '6c7014e84a5e'
from alembic import op as original_op
from data.migrations.progress import ProgressWrapper
import sqlalchemy as sa
from util.migrate import UTF8CharField
def upgrade(tables, tester, progress_reporter):
op = ProgressWrapper(original_op, progress_reporter)
### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('company', UTF8CharField(length=255), nullable=True))
op.add_column('user', sa.Column('family_name', UTF8CharField(length=255), nullable=True))
op.add_column('user', sa.Column('given_name', UTF8CharField(length=255), nullable=True))
### end Alembic commands ###
op.bulk_insert(tables.userpromptkind,
[
{'name':'enter_name'},
{'name':'enter_company'},
])
# ### population of test data ### #
tester.populate_column('user', 'company', tester.TestDataType.UTF8Char)
tester.populate_column('user', 'family_name', tester.TestDataType.UTF8Char)
tester.populate_column('user', 'given_name', tester.TestDataType.UTF8Char)
# ### end population of test data ### #
def downgrade(tables, tester, progress_reporter):
op = ProgressWrapper(original_op, progress_reporter)
### commands auto generated by Alembic - please adjust! ###
op.drop_column('user', 'given_name')
op.drop_column('user', 'family_name')
op.drop_column('user', 'company')
### end Alembic commands ###
op.execute(
(tables.userpromptkind.delete()
.where(tables.userpromptkind.c.name == op.inline_literal('enter_name')))
)
op.execute(
(tables.userpromptkind.delete()
.where(tables.userpromptkind.c.name == op.inline_literal('enter_company')))
)