2016-11-04 21:57:55 +00:00
|
|
|
"""Add user metadata fields
|
|
|
|
|
2016-11-09 20:29:53 +00:00
|
|
|
Revision ID: faf752bd2e0a
|
2016-11-04 21:57:55 +00:00
|
|
|
Revises: 6c7014e84a5e
|
2016-11-09 20:29:53 +00:00
|
|
|
Create Date: 2016-11-14 17:29:03.984665
|
2016-11-04 21:57:55 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
2016-11-09 20:29:53 +00:00
|
|
|
revision = 'faf752bd2e0a'
|
2016-11-04 21:57:55 +00:00
|
|
|
down_revision = '6c7014e84a5e'
|
|
|
|
|
|
|
|
from alembic import op
|
|
|
|
import sqlalchemy as sa
|
2016-11-09 20:29:53 +00:00
|
|
|
|
2016-11-04 21:57:55 +00:00
|
|
|
from util.migrate import UTF8CharField
|
|
|
|
|
2018-05-07 13:45:57 +00:00
|
|
|
def upgrade(tables, tester):
|
2016-11-04 21:57:55 +00:00
|
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
|
|
op.add_column('user', sa.Column('company', UTF8CharField(length=255), nullable=True))
|
2016-11-09 20:29:53 +00:00
|
|
|
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))
|
2016-11-04 21:57:55 +00:00
|
|
|
### end Alembic commands ###
|
|
|
|
|
|
|
|
op.bulk_insert(tables.userpromptkind,
|
|
|
|
[
|
|
|
|
{'name':'enter_name'},
|
|
|
|
{'name':'enter_company'},
|
|
|
|
])
|
|
|
|
|
2018-05-07 13:45:57 +00:00
|
|
|
# ### 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 ### #
|
2016-11-04 21:57:55 +00:00
|
|
|
|
2018-05-07 13:45:57 +00:00
|
|
|
|
|
|
|
def downgrade(tables, tester):
|
2016-11-04 21:57:55 +00:00
|
|
|
### commands auto generated by Alembic - please adjust! ###
|
2016-11-09 20:29:53 +00:00
|
|
|
op.drop_column('user', 'given_name')
|
|
|
|
op.drop_column('user', 'family_name')
|
2016-11-04 21:57:55 +00:00
|
|
|
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')))
|
|
|
|
)
|