mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-10 08:05:22 +02:00
104 lines
3.6 KiB
Python
104 lines
3.6 KiB
Python
"""add organisation table
|
|
|
|
Revision ID: f6f19156bcb7
|
|
Revises: 5253971e3f03
|
|
Create Date: 2025-06-09 15:12:14.636802
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "f6f19156bcb7"
|
|
down_revision: Union[str, None] = "5253971e3f03"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"organizations",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("provider_id", sa.String(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_organizations_id"), "organizations", ["id"], unique=False)
|
|
op.create_index(
|
|
op.f("ix_organizations_provider_id"),
|
|
"organizations",
|
|
["provider_id"],
|
|
unique=True,
|
|
)
|
|
op.create_table(
|
|
"organization_users",
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.Column("organization_id", sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["organization_id"],
|
|
["organizations.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["users.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("user_id", "organization_id"),
|
|
)
|
|
op.drop_index("ix_livekit_rooms_id", table_name="livekit_rooms")
|
|
op.drop_index("ix_livekit_rooms_name", table_name="livekit_rooms")
|
|
op.drop_index("ix_livekit_rooms_state", table_name="livekit_rooms")
|
|
op.drop_index("ix_livekit_rooms_type", table_name="livekit_rooms")
|
|
op.drop_table("livekit_rooms")
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"livekit_rooms",
|
|
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
|
|
sa.Column(
|
|
"type",
|
|
postgresql.ENUM("VOICE", "TEXT", "VIDEO", name="room_type"),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"state",
|
|
postgresql.ENUM(
|
|
"CONNECTED",
|
|
"DISCONNECTED",
|
|
"RECONNECTING",
|
|
"RECONNECTED",
|
|
name="room_state",
|
|
),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=False),
|
|
sa.Column(
|
|
"created_at",
|
|
postgresql.TIMESTAMP(timezone=True),
|
|
autoincrement=False,
|
|
nullable=True,
|
|
),
|
|
sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"], ["users.id"], name="livekit_rooms_user_id_fkey"
|
|
),
|
|
sa.PrimaryKeyConstraint("id", name="livekit_rooms_pkey"),
|
|
)
|
|
op.create_index("ix_livekit_rooms_type", "livekit_rooms", ["type"], unique=False)
|
|
op.create_index("ix_livekit_rooms_state", "livekit_rooms", ["state"], unique=False)
|
|
op.create_index("ix_livekit_rooms_name", "livekit_rooms", ["name"], unique=False)
|
|
op.create_index("ix_livekit_rooms_id", "livekit_rooms", ["id"], unique=False)
|
|
op.drop_table("organization_users")
|
|
op.drop_index(op.f("ix_organizations_provider_id"), table_name="organizations")
|
|
op.drop_index(op.f("ix_organizations_id"), table_name="organizations")
|
|
op.drop_table("organizations")
|
|
# ### end Alembic commands ###
|