Skip to content

Commit

Permalink
Add missing migration
Browse files Browse the repository at this point in the history
  • Loading branch information
stefannica committed Feb 26, 2025
1 parent ff640bc commit 9404ab4
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""add user default workspace [2e695a26fe7a].
Revision ID: 2e695a26fe7a
Revises: 1f9d1cd00b90
Create Date: 2025-02-24 18:19:43.121393
"""

import sqlalchemy as sa
import sqlmodel
from alembic import op

# revision identifiers, used by Alembic.
revision = "2e695a26fe7a"
down_revision = "1f9d1cd00b90"
branch_labels = None
depends_on = None


def upgrade() -> None:
"""Upgrade database schema and/or data, creating a new revision."""
with op.batch_alter_table("user", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"default_workspace_id",
sqlmodel.sql.sqltypes.GUID(),
nullable=True,
)
)
batch_op.create_foreign_key(
"fk_user_default_workspace_id_workspace",
"workspace",
["default_workspace_id"],
["id"],
ondelete="SET NULL",
)


def downgrade() -> None:
"""Downgrade database schema and/or data back to the previous revision."""
with op.batch_alter_table("user", schema=None) as batch_op:
batch_op.drop_constraint(
"fk_user_default_workspace_id_workspace", type_="foreignkey"
)
batch_op.drop_column("default_workspace_id")

0 comments on commit 9404ab4

Please sign in to comment.