in migrations/versions/e3282e2db2d7_.py [0:0]
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,
)