initial commit
This commit is contained in:
0
migrations/versions/.gitkeep
Normal file
0
migrations/versions/.gitkeep
Normal file
103
migrations/versions/20260327_0001_initial.py
Normal file
103
migrations/versions/20260327_0001_initial.py
Normal file
@@ -0,0 +1,103 @@
|
||||
"""initial tables
|
||||
|
||||
Revision ID: 20260327_0001
|
||||
Revises:
|
||||
Create Date: 2026-03-27 00:00:00.000000
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "20260327_0001"
|
||||
down_revision: str | None = None
|
||||
branch_labels: Sequence[str] | None = None
|
||||
depends_on: Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"issues_cache",
|
||||
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
||||
sa.Column("glitchtip_issue_id", sa.BigInteger(), nullable=False),
|
||||
sa.Column("project_slug", sa.String(length=255), nullable=False),
|
||||
sa.Column("title", sa.Text(), nullable=False),
|
||||
sa.Column("culprit", sa.Text(), nullable=True),
|
||||
sa.Column("level", sa.String(length=50), nullable=False),
|
||||
sa.Column("status", sa.String(length=50), nullable=False),
|
||||
sa.Column("first_seen", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("last_seen", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("event_count", sa.Integer(), nullable=False),
|
||||
sa.Column("is_regression", sa.Boolean(), nullable=False),
|
||||
sa.Column("link", sa.Text(), nullable=True),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_issues_cache_glitchtip_issue_id"),
|
||||
"issues_cache",
|
||||
["glitchtip_issue_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_issues_cache_project_slug"), "issues_cache", ["project_slug"], unique=False
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"notifications_sent",
|
||||
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
||||
sa.Column("issue_id", sa.BigInteger(), nullable=False),
|
||||
sa.Column("notification_type", sa.String(length=50), nullable=False),
|
||||
sa.Column("fingerprint", sa.String(length=255), nullable=False),
|
||||
sa.Column(
|
||||
"sent_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_notifications_sent_fingerprint"),
|
||||
"notifications_sent",
|
||||
["fingerprint"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_notifications_sent_issue_id"), "notifications_sent", ["issue_id"], unique=False
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"sync_state",
|
||||
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
||||
sa.Column("source", sa.String(length=100), nullable=False),
|
||||
sa.Column("last_successful_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
op.create_index(op.f("ix_sync_state_source"), "sync_state", ["source"], unique=True)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f("ix_sync_state_source"), table_name="sync_state")
|
||||
op.drop_table("sync_state")
|
||||
|
||||
op.drop_index(op.f("ix_notifications_sent_issue_id"), table_name="notifications_sent")
|
||||
op.drop_index(op.f("ix_notifications_sent_fingerprint"), table_name="notifications_sent")
|
||||
op.drop_table("notifications_sent")
|
||||
|
||||
op.drop_index(op.f("ix_issues_cache_project_slug"), table_name="issues_cache")
|
||||
op.drop_index(op.f("ix_issues_cache_glitchtip_issue_id"), table_name="issues_cache")
|
||||
op.drop_table("issues_cache")
|
||||
162
migrations/versions/20260327_0002_runtime_features.py
Normal file
162
migrations/versions/20260327_0002_runtime_features.py
Normal file
@@ -0,0 +1,162 @@
|
||||
"""runtime features
|
||||
|
||||
Revision ID: 20260327_0002
|
||||
Revises: 20260327_0001
|
||||
Create Date: 2026-03-27 00:30:00.000000
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "20260327_0002"
|
||||
down_revision: str | None = "20260327_0001"
|
||||
branch_labels: Sequence[str] | None = None
|
||||
depends_on: Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column("issues_cache", sa.Column("release", sa.String(length=255), nullable=True))
|
||||
|
||||
op.add_column(
|
||||
"notifications_sent", sa.Column("project_slug", sa.String(length=255), nullable=True)
|
||||
)
|
||||
op.add_column(
|
||||
"notifications_sent", sa.Column("group_name", sa.String(length=50), nullable=True)
|
||||
)
|
||||
op.add_column("notifications_sent", sa.Column("priority", sa.String(length=20), nullable=True))
|
||||
op.add_column(
|
||||
"notifications_sent",
|
||||
sa.Column("delivery_status", sa.String(length=50), nullable=False, server_default="sent"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_notifications_sent_group_name"),
|
||||
"notifications_sent",
|
||||
["group_name"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"mute_rules",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("pattern", sa.Text(), nullable=False),
|
||||
sa.Column("description", sa.Text(), nullable=True),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.text("true")),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
op.create_unique_constraint("uq_mute_rules_pattern", "mute_rules", ["pattern"])
|
||||
|
||||
op.create_table(
|
||||
"project_ownership_overrides",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("project_slug", sa.String(length=255), nullable=False),
|
||||
sa.Column("group_name", sa.String(length=50), nullable=False),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_project_ownership_overrides_project_slug"),
|
||||
"project_ownership_overrides",
|
||||
["project_slug"],
|
||||
unique=True,
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"group_topic_overrides",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("group_name", sa.String(length=50), nullable=False),
|
||||
sa.Column("topic_id", sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_group_topic_overrides_group_name"),
|
||||
"group_topic_overrides",
|
||||
["group_name"],
|
||||
unique=True,
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"group_subscriber_overrides",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("group_name", sa.String(length=50), nullable=False),
|
||||
sa.Column("user_id", sa.BigInteger(), nullable=False),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.UniqueConstraint("group_name", "user_id", name="uq_group_subscriber"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_group_subscriber_overrides_group_name"),
|
||||
"group_subscriber_overrides",
|
||||
["group_name"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_group_subscriber_overrides_user_id"),
|
||||
"group_subscriber_overrides",
|
||||
["user_id"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(
|
||||
op.f("ix_group_subscriber_overrides_user_id"),
|
||||
table_name="group_subscriber_overrides",
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_group_subscriber_overrides_group_name"),
|
||||
table_name="group_subscriber_overrides",
|
||||
)
|
||||
op.drop_table("group_subscriber_overrides")
|
||||
|
||||
op.drop_index(op.f("ix_group_topic_overrides_group_name"), table_name="group_topic_overrides")
|
||||
op.drop_table("group_topic_overrides")
|
||||
|
||||
op.drop_index(
|
||||
op.f("ix_project_ownership_overrides_project_slug"),
|
||||
table_name="project_ownership_overrides",
|
||||
)
|
||||
op.drop_table("project_ownership_overrides")
|
||||
|
||||
op.drop_constraint("uq_mute_rules_pattern", "mute_rules", type_="unique")
|
||||
op.drop_table("mute_rules")
|
||||
|
||||
op.drop_index(op.f("ix_notifications_sent_group_name"), table_name="notifications_sent")
|
||||
op.drop_column("notifications_sent", "delivery_status")
|
||||
op.drop_column("notifications_sent", "priority")
|
||||
op.drop_column("notifications_sent", "group_name")
|
||||
op.drop_column("notifications_sent", "project_slug")
|
||||
|
||||
op.drop_column("issues_cache", "release")
|
||||
Reference in New Issue
Block a user