Skip to content

Commit 0b3da76

Browse files
Authorization via Teams (#182)
* generated alembic version for team tables * updates submodule model * updates submodule * Removes unwanted files (#190) * Adds better session handling (#188) * Adds better session handling * Readds faulty removed code line * Submodule update --------- Co-authored-by: JWittmeyer <[email protected]>
1 parent 1ce6030 commit 0b3da76

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"""adds team tables
2+
3+
Revision ID: 7de3c19cddcf
4+
Revises: 6b7c123b3e52
5+
Create Date: 2024-02-09 12:26:58.403086
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
from sqlalchemy.dialects import postgresql
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "7de3c19cddcf"
15+
down_revision = "6b7c123b3e52"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.create_table(
23+
"team",
24+
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
25+
sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True),
26+
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
27+
sa.Column("created_at", sa.DateTime(), nullable=True),
28+
sa.Column("name", sa.String(), nullable=True),
29+
sa.Column("description", sa.String(), nullable=True),
30+
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
31+
sa.ForeignKeyConstraint(
32+
["organization_id"], ["organization.id"], ondelete="CASCADE"
33+
),
34+
sa.PrimaryKeyConstraint("id"),
35+
)
36+
op.create_index(op.f("ix_team_created_by"), "team", ["created_by"], unique=False)
37+
op.create_index(
38+
op.f("ix_team_organization_id"), "team", ["organization_id"], unique=False
39+
)
40+
op.create_table(
41+
"team_member",
42+
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
43+
sa.Column("team_id", postgresql.UUID(as_uuid=True), nullable=True),
44+
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=True),
45+
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
46+
sa.Column("created_at", sa.DateTime(), nullable=True),
47+
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
48+
sa.ForeignKeyConstraint(["team_id"], ["team.id"], ondelete="CASCADE"),
49+
sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="CASCADE"),
50+
sa.PrimaryKeyConstraint("id"),
51+
)
52+
op.create_index(
53+
op.f("ix_team_member_created_by"), "team_member", ["created_by"], unique=False
54+
)
55+
op.create_index(
56+
op.f("ix_team_member_team_id"), "team_member", ["team_id"], unique=False
57+
)
58+
op.create_index(
59+
op.f("ix_team_member_user_id"), "team_member", ["user_id"], unique=False
60+
)
61+
op.create_table(
62+
"team_resource",
63+
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
64+
sa.Column("team_id", postgresql.UUID(as_uuid=True), nullable=True),
65+
sa.Column("resource_id", postgresql.UUID(as_uuid=True), nullable=True),
66+
sa.Column("resource_type", sa.String(), nullable=True),
67+
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
68+
sa.Column("created_at", sa.DateTime(), nullable=True),
69+
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
70+
sa.ForeignKeyConstraint(["team_id"], ["team.id"], ondelete="CASCADE"),
71+
sa.PrimaryKeyConstraint("id"),
72+
)
73+
op.create_index(
74+
op.f("ix_team_resource_created_by"),
75+
"team_resource",
76+
["created_by"],
77+
unique=False,
78+
)
79+
op.create_index(
80+
op.f("ix_team_resource_resource_id"),
81+
"team_resource",
82+
["resource_id"],
83+
unique=False,
84+
)
85+
op.create_index(
86+
op.f("ix_team_resource_team_id"), "team_resource", ["team_id"], unique=False
87+
)
88+
# ### end Alembic commands ###
89+
90+
91+
def downgrade():
92+
# ### commands auto generated by Alembic - please adjust! ###
93+
op.drop_index(op.f("ix_team_resource_team_id"), table_name="team_resource")
94+
op.drop_index(op.f("ix_team_resource_resource_id"), table_name="team_resource")
95+
op.drop_index(op.f("ix_team_resource_created_by"), table_name="team_resource")
96+
op.drop_table("team_resource")
97+
op.drop_index(op.f("ix_team_member_user_id"), table_name="team_member")
98+
op.drop_index(op.f("ix_team_member_team_id"), table_name="team_member")
99+
op.drop_index(op.f("ix_team_member_created_by"), table_name="team_member")
100+
op.drop_table("team_member")
101+
op.drop_index(op.f("ix_team_organization_id"), table_name="team")
102+
op.drop_index(op.f("ix_team_created_by"), table_name="team")
103+
op.drop_table("team")
104+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)