Add a migration for team member invites.

This commit is contained in:
Jake Moshenko 2014-09-15 23:57:05 -04:00
parent 75d2ef377e
commit e13c027631

View file

@ -1,20 +1,20 @@
"""Add support for team member invites
"""Email invites for joining a team.
Revision ID: 25aea439ad0e
Revises: 82297d834ad
Create Date: 2014-08-18 20:40:38.553951
Revision ID: 51d04d0e7e6f
Revises: 34fd69f63809
Create Date: 2014-09-15 23:51:35.478232
"""
# revision identifiers, used by Alembic.
revision = '25aea439ad0e'
down_revision = '82297d834ad'
revision = '51d04d0e7e6f'
down_revision = '34fd69f63809'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
def upgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.create_table('teammemberinvite',
sa.Column('id', sa.Integer(), nullable=False),
@ -33,46 +33,39 @@ def upgrade():
op.create_index('teammemberinvite_user_id', 'teammemberinvite', ['user_id'], unique=False)
### end Alembic commands ###
schema = gen_sqlalchemy_metadata(all_models)
# Manually add the new logentrykind types
op.bulk_insert(schema.tables['logentrykind'],
op.bulk_insert(tables.logentrykind,
[
{'id':41, 'name':'org_invite_team_member'},
{'id':42, 'name':'org_team_member_invite_accepted'},
{'id':43, 'name':'org_team_member_invite_declined'},
{'id':44, 'name':'org_delete_team_member_invite'},
{'id':42, 'name':'org_invite_team_member'},
{'id':43, 'name':'org_team_member_invite_accepted'},
{'id':44, 'name':'org_team_member_invite_declined'},
{'id':45, 'name':'org_delete_team_member_invite'},
])
def downgrade():
def downgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.execute(
(tables.logentrykind.delete()
.where(tables.logentrykind.c.name == op.inline_literal('org_invite_team_member')))
)
op.execute(
(tables.logentrykind.delete()
.where(tables.logentrykind.c.name == op.inline_literal('org_team_member_invite_accepted')))
)
op.execute(
(tables.logentrykind.delete()
.where(tables.logentrykind.c.name == op.inline_literal('org_team_member_invite_declined')))
)
op.execute(
(tables.logentrykind.delete()
.where(tables.logentrykind.c.name == op.inline_literal('org_delete_team_member_invite')))
)
op.drop_index('teammemberinvite_user_id', table_name='teammemberinvite')
op.drop_index('teammemberinvite_team_id', table_name='teammemberinvite')
op.drop_index('teammemberinvite_inviter_id', table_name='teammemberinvite')
op.drop_table('teammemberinvite')
### end Alembic commands ###
schema = gen_sqlalchemy_metadata(all_models)
logentrykind = schema.tables['logentrykind']
op.execute(
(logentrykind.delete()
.where(logentrykind.c.name == op.inline_literal('org_invite_team_member')))
)
op.execute(
(logentrykind.delete()
.where(logentrykind.c.name == op.inline_literal('org_team_member_invite_accepted')))
)
op.execute(
(logentrykind.delete()
.where(logentrykind.c.name == op.inline_literal('org_team_member_invite_declined')))
)
op.execute(
(logentrykind.delete()
.where(logentrykind.c.name == op.inline_literal('org_delete_team_member_invite')))
)