8aad2ab43d
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Dashboard layout tables
|
|
|
|
Revision ID: 0005_dashboards
|
|
Revises: 0004_app_settings
|
|
Create Date: 2026-03-22
|
|
"""
|
|
from typing import Sequence, Union
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision: str = "0005_dashboards"
|
|
down_revision: Union[str, None] = "0004_app_settings"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"dashboards",
|
|
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
|
sa.Column("name", sa.String(128), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
)
|
|
op.create_table(
|
|
"dashboard_widgets",
|
|
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
|
sa.Column("dashboard_id", sa.Integer,
|
|
sa.ForeignKey("dashboards.id", ondelete="CASCADE"), nullable=False),
|
|
sa.Column("widget_key", sa.String(64), nullable=False),
|
|
sa.Column("position", sa.Integer, nullable=False),
|
|
)
|
|
op.create_index(
|
|
"ix_dashboard_widgets_dashboard_id",
|
|
"dashboard_widgets", ["dashboard_id"],
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_dashboard_widgets_dashboard_id", "dashboard_widgets")
|
|
op.drop_table("dashboard_widgets")
|
|
op.drop_table("dashboards")
|