initial commit
This commit is contained in:
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")
|
||||
Reference in New Issue
Block a user