39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""create environment_roles table
|
|
|
|
Revision ID: c1d074288e99
|
|
Revises: 06aa23166ca9
|
|
Create Date: 2018-09-06 13:40:12.332241
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'c1d074288e99'
|
|
down_revision = '06aa23166ca9'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('environment_roles',
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), server_default=sa.text('uuid_generate_v4()'), nullable=False),
|
|
sa.Column('environment_id', postgresql.UUID(as_uuid=True), nullable=True),
|
|
sa.Column('role', sa.String(), nullable=True),
|
|
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=True),
|
|
sa.ForeignKeyConstraint(['environment_id'], ['environments.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('environments_role_user_environment', 'environment_roles', ['user_id', 'environment_id'], unique=True)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index('environments_role_user_environment', table_name='environment_roles')
|
|
op.drop_table('environment_roles')
|
|
# ### end Alembic commands ###
|