migrations/versions/e3282e2db2d7_.py (141 lines of code) (raw):

"""empty message Revision ID: e3282e2db2d7 Revises: 068674f06b0f Create Date: 2019-06-17 18:34:11.058440 """ from alembic import op import sqlalchemy as sa from backend.models.postgis.statuses import TeamVisibility # revision identifiers, used by Alembic. revision = "e3282e2db2d7" down_revision = "d2e18f0f34a9" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "organisations", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=512), nullable=False), sa.Column("logo", sa.String(), nullable=True), sa.Column("url", sa.String(), nullable=True), sa.PrimaryKeyConstraint("id") # , # sa.UniqueConstraint("name"), ) op.create_table( "organisation_managers", sa.Column("organisation_id", sa.Integer(), nullable=False), sa.Column("user_id", sa.BigInteger(), nullable=False), sa.ForeignKeyConstraint(["organisation_id"], ["organisations.id"]), sa.ForeignKeyConstraint(["user_id"], ["users.id"]), ) op.create_table( "teams", sa.Column("id", sa.Integer(), nullable=False), sa.Column("organisation_id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=512), nullable=False), sa.Column("logo", sa.String(), nullable=True), sa.Column("description", sa.String(), nullable=True), sa.Column("invite_only", sa.Boolean(), nullable=False), sa.Column( "visibility", sa.Integer(), nullable=False, server_default=str(TeamVisibility.PRIVATE.value), ), sa.ForeignKeyConstraint( ["organisation_id"], ["organisations.id"], name="fk_organisations" ), sa.PrimaryKeyConstraint("id"), ) op.create_table( "project_teams", sa.Column("team_id", sa.Integer(), nullable=False), sa.Column("project_id", sa.Integer(), nullable=False), sa.Column("role", sa.Integer(), nullable=False), sa.ForeignKeyConstraint(["project_id"], ["projects.id"]), sa.ForeignKeyConstraint(["team_id"], ["teams.id"]), sa.PrimaryKeyConstraint("team_id", "project_id"), ) op.create_table( "team_members", sa.Column("team_id", sa.Integer(), nullable=False), sa.Column("user_id", sa.BigInteger(), nullable=False), sa.Column("function", sa.Integer(), nullable=False), sa.ForeignKeyConstraint(["team_id"], ["teams.id"], name="fk_teams"), sa.ForeignKeyConstraint(["user_id"], ["users.id"], name="fk_users"), sa.PrimaryKeyConstraint("team_id", "user_id"), ) op.add_column("projects", sa.Column("organisation_id", sa.Integer(), nullable=True)) op.alter_column( "projects", "task_creation_mode", existing_type=sa.INTEGER(), nullable=False ) op.create_index( op.f("ix_projects_organisation_id"), "projects", ["organisation_id"], unique=False, ) op.create_foreign_key( "fk_organisations", "projects", "organisations", ["organisation_id"], ["id"] ) op.drop_index( "idx_task_validation_mapper_status_composite", table_name="task_invalidation_history", ) op.create_index( "idx_task_validation_mapper_status_composite", "task_invalidation_history", ["mapper_id", "is_closed"], unique=False, ) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "campaigns", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("logo", sa.String(), nullable=True), sa.Column("url", sa.String(), nullable=True), sa.Column("description", sa.String(), nullable=True), sa.PrimaryKeyConstraint("id"), ) op.create_table( "campaign_projects", sa.Column("campaign_id", sa.Integer(), nullable=True), sa.Column("project_id", sa.Integer(), nullable=True), sa.ForeignKeyConstraint(["campaign_id"], ["campaigns.id"]), sa.ForeignKeyConstraint(["project_id"], ["projects.id"]), ) op.create_table( "campaign_organisations", sa.Column("campaign_id", sa.Integer(), nullable=True), sa.Column("organisation_id", sa.Integer(), nullable=True), sa.ForeignKeyConstraint(["campaign_id"], ["campaigns.id"]), sa.ForeignKeyConstraint(["organisation_id"], ["organisations.id"]), ) op.drop_index( "idx_task_validation_mapper_status_composite", table_name="task_invalidation_history", ) op.create_index( "idx_task_validation_mapper_status_composite", "task_invalidation_history", ["invalidator_id", "is_closed"], unique=False, ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index( "idx_task_validation_mapper_status_composite", table_name="task_invalidation_history", ) op.create_index( "idx_task_validation_mapper_status_composite", "task_invalidation_history", ["invalidator_id", "is_closed"], unique=False, ) op.drop_constraint("fk_organisations", "projects", type_="foreignkey") op.drop_index(op.f("ix_projects_organisation_id"), table_name="projects") op.alter_column( "projects", "task_creation_mode", existing_type=sa.INTEGER(), nullable=True ) op.drop_column("projects", "organisation_id") op.drop_table("team_members") op.drop_table("project_teams") op.drop_table("teams") op.drop_table("campaign_organisations") op.drop_table("campaign_projects") op.drop_table("campaigns") op.drop_table("organisation_managers") op.drop_table("organisations") # ### end Alembic commands ###