Database changes for new portfolio invitation flow.
- user_id is nullable on role tables - invitation tables hold basic user information
This commit is contained in:
parent
4e0cc26b5f
commit
755fabd725
@ -0,0 +1,54 @@
|
|||||||
|
"""add user data fields to invitations
|
||||||
|
|
||||||
|
Revision ID: 8467440c4ae6
|
||||||
|
Revises: d2390c547dca
|
||||||
|
Create Date: 2019-05-31 12:40:10.457529
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '8467440c4ae6'
|
||||||
|
down_revision = 'd2390c547dca'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('application_invitations', sa.Column('dod_id', sa.String(), nullable=True))
|
||||||
|
op.add_column('application_invitations', sa.Column('first_name', sa.String(), nullable=True))
|
||||||
|
op.add_column('application_invitations', sa.Column('last_name', sa.String(), nullable=True))
|
||||||
|
op.add_column('application_invitations', sa.Column('phone_number', sa.String(), nullable=True))
|
||||||
|
op.alter_column('application_roles', 'user_id',
|
||||||
|
existing_type=postgresql.UUID(),
|
||||||
|
nullable=True)
|
||||||
|
op.add_column('portfolio_invitations', sa.Column('dod_id', sa.String(), nullable=True))
|
||||||
|
op.add_column('portfolio_invitations', sa.Column('first_name', sa.String(), nullable=True))
|
||||||
|
op.add_column('portfolio_invitations', sa.Column('last_name', sa.String(), nullable=True))
|
||||||
|
op.add_column('portfolio_invitations', sa.Column('phone_number', sa.String(), nullable=True))
|
||||||
|
op.alter_column('portfolio_roles', 'user_id',
|
||||||
|
existing_type=postgresql.UUID(),
|
||||||
|
nullable=True)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.alter_column('portfolio_roles', 'user_id',
|
||||||
|
existing_type=postgresql.UUID(),
|
||||||
|
nullable=True)
|
||||||
|
op.drop_column('portfolio_invitations', 'phone_number')
|
||||||
|
op.drop_column('portfolio_invitations', 'last_name')
|
||||||
|
op.drop_column('portfolio_invitations', 'first_name')
|
||||||
|
op.drop_column('portfolio_invitations', 'dod_id')
|
||||||
|
op.alter_column('application_roles', 'user_id',
|
||||||
|
existing_type=postgresql.UUID(),
|
||||||
|
nullable=True)
|
||||||
|
op.drop_column('application_invitations', 'phone_number')
|
||||||
|
op.drop_column('application_invitations', 'last_name')
|
||||||
|
op.drop_column('application_invitations', 'first_name')
|
||||||
|
op.drop_column('application_invitations', 'dod_id')
|
||||||
|
# ### end Alembic commands ###
|
@ -42,7 +42,7 @@ class ApplicationRole(
|
|||||||
application = relationship("Application", back_populates="roles")
|
application = relationship("Application", back_populates="roles")
|
||||||
|
|
||||||
user_id = Column(
|
user_id = Column(
|
||||||
UUID(as_uuid=True), ForeignKey("users.id"), index=True, nullable=False
|
UUID(as_uuid=True), ForeignKey("users.id"), index=True, nullable=True
|
||||||
)
|
)
|
||||||
|
|
||||||
status = Column(SQLAEnum(Status, native_enum=False), default=Status.PENDING)
|
status = Column(SQLAEnum(Status, native_enum=False), default=Status.PENDING)
|
||||||
|
@ -45,6 +45,11 @@ class InvitesMixin(object):
|
|||||||
|
|
||||||
email = Column(String, nullable=False)
|
email = Column(String, nullable=False)
|
||||||
|
|
||||||
|
dod_id = Column(String)
|
||||||
|
first_name = Column(String)
|
||||||
|
last_name = Column(String)
|
||||||
|
phone_number = Column(String)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
role_id = self.role.id if self.role else None
|
role_id = self.role.id if self.role else None
|
||||||
return "<{}(user='{}', role='{}', id='{}', email='{}')>".format(
|
return "<{}(user='{}', role='{}', id='{}', email='{}')>".format(
|
||||||
|
@ -48,7 +48,7 @@ class PortfolioRole(
|
|||||||
portfolio = relationship("Portfolio", back_populates="roles")
|
portfolio = relationship("Portfolio", back_populates="roles")
|
||||||
|
|
||||||
user_id = Column(
|
user_id = Column(
|
||||||
UUID(as_uuid=True), ForeignKey("users.id"), index=True, nullable=False
|
UUID(as_uuid=True), ForeignKey("users.id"), index=True, nullable=True
|
||||||
)
|
)
|
||||||
|
|
||||||
status = Column(SQLAEnum(Status, native_enum=False), default=Status.PENDING)
|
status = Column(SQLAEnum(Status, native_enum=False), default=Status.PENDING)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user