Skip to content

Commit

Permalink
refactor: merged the runbook patches into signle one and remov the pr…
Browse files Browse the repository at this point in the history
…evious patches related to runbooks
  • Loading branch information
rajesh-jonnalagadda committed Oct 13, 2024
1 parent 4696517 commit 815df21
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 73 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"""Add runbook tables
"""add runbook schema
Revision ID: 0796be640663
Revision ID: 8af72e1df141
Revises: bf756df80e9d
Create Date: 2024-10-08 22:23:47.905179
Create Date: 2024-10-13 08:33:24.727292
"""

import sqlalchemy as sa
import sqlalchemy_utils
import sqlmodel
from alembic import op

# revision identifiers, used by Alembic.
revision = "0796be640663"
revision = "8af72e1df141"
down_revision = "bf756df80e9d"
branch_labels = None
depends_on = None
Expand All @@ -24,6 +25,7 @@ def upgrade() -> None:
sa.Column("tenant_id", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column("relative_path", sa.Text(), nullable=True),
sa.Column("title", sa.Text(), nullable=True),
sa.Column("timestamp", sa.DateTime(), nullable=True),
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("repo_id", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("provider_type", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
Expand All @@ -32,6 +34,11 @@ def upgrade() -> None:
sa.ForeignKeyConstraint(["tenant_id"], ["tenant.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
with op.batch_alter_table("runbook", schema=None) as batch_op:
batch_op.create_index(
batch_op.f("ix_runbook_timestamp"), ["timestamp"], unique=False
)

op.create_table(
"runbookcontent",
sa.Column("runbook_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
Expand All @@ -44,11 +51,43 @@ def upgrade() -> None:
sa.ForeignKeyConstraint(["runbook_id"], ["runbook.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"runbooktoincident",
sa.Column(
"incident_id",
sqlalchemy_utils.types.uuid.UUIDType(binary=False),
nullable=False,
),
sa.Column("tenant_id", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("runbook_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("timestamp", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(["incident_id"], ["incident.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(
["runbook_id"],
["runbook.id"],
),
sa.ForeignKeyConstraint(
["tenant_id"],
["tenant.id"],
),
sa.PrimaryKeyConstraint("incident_id", "runbook_id"),
)

with op.batch_alter_table("incident", schema=None) as batch_op:
batch_op.add_column(sa.Column("runbooks_count", sa.Integer(), nullable=False))

# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("incident", schema=None) as batch_op:
batch_op.drop_column("runbooks_count")

op.drop_table("runbooktoincident")
op.drop_table("runbookcontent")
with op.batch_alter_table("runbook", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_runbook_timestamp"))

op.drop_table("runbook")
# ### end Alembic commands ###

0 comments on commit 815df21

Please sign in to comment.