artifacts-dashboard/backend/alembic/versions/002_add_automation_tables.py
Paweł Orzech f845647934
Some checks failed
Release / release (push) Has been cancelled
Initial release: Artifacts MMO Dashboard & Automation Platform
Full-stack dashboard for controlling, automating, and analyzing
Artifacts MMO characters via the game's HTTP API.

Backend (FastAPI):
- Async Artifacts API client with rate limiting and retry
- 6 automation strategies (combat, gathering, crafting, trading, task, leveling)
- Automation engine with runner, manager, cooldown tracker, pathfinder
- WebSocket relay (game server -> frontend)
- Game data cache, character snapshots, price history, analytics
- 9 API routers, 7 database tables, 3 Alembic migrations
- 108 unit tests

Frontend (Next.js 15 + shadcn/ui):
- Live character dashboard with HP/XP bars and cooldowns
- Character detail with stats, equipment, inventory, skills, manual actions
- Automation management with live log streaming
- Interactive canvas map with content-type coloring and zoom/pan
- Bank management, Grand Exchange with price charts
- Events, logs, analytics pages with Recharts
- WebSocket auto-reconnect with query cache invalidation
- Settings page, error boundaries, dark theme

Infrastructure:
- Docker Compose (dev + prod)
- GitHub Actions CI/CD
- Documentation (Architecture, Automation, Deployment, API)
2026-03-01 19:46:45 +01:00

126 lines
4 KiB
Python

"""Add automation_configs, automation_runs, automation_logs tables
Revision ID: 002_automation
Revises: 001_initial
Create Date: 2026-03-01
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "002_automation"
down_revision: Union[str, None] = "001_initial"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# automation_configs
op.create_table(
"automation_configs",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("name", sa.String(length=100), nullable=False),
sa.Column("character_name", sa.String(length=100), nullable=False),
sa.Column(
"strategy_type",
sa.String(length=50),
nullable=False,
comment="Strategy type: combat, gathering, crafting, trading, task, leveling",
),
sa.Column("config", sa.JSON(), nullable=False),
sa.Column("enabled", sa.Boolean(), nullable=False, server_default=sa.text("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,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_automation_configs_character_name"),
"automation_configs",
["character_name"],
unique=False,
)
# automation_runs
op.create_table(
"automation_runs",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column(
"config_id",
sa.Integer(),
sa.ForeignKey("automation_configs.id", ondelete="CASCADE"),
nullable=False,
),
sa.Column(
"status",
sa.String(length=20),
nullable=False,
server_default=sa.text("'running'"),
comment="Status: running, paused, stopped, completed, error",
),
sa.Column(
"started_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column("stopped_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("actions_count", sa.Integer(), nullable=False, server_default=sa.text("0")),
sa.Column("error_message", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_automation_runs_config_id"),
"automation_runs",
["config_id"],
unique=False,
)
# automation_logs
op.create_table(
"automation_logs",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column(
"run_id",
sa.Integer(),
sa.ForeignKey("automation_runs.id", ondelete="CASCADE"),
nullable=False,
),
sa.Column("action_type", sa.String(length=50), nullable=False),
sa.Column("details", sa.JSON(), nullable=False),
sa.Column("success", sa.Boolean(), nullable=False, server_default=sa.text("true")),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_automation_logs_run_id"),
"automation_logs",
["run_id"],
unique=False,
)
def downgrade() -> None:
op.drop_index(op.f("ix_automation_logs_run_id"), table_name="automation_logs")
op.drop_table("automation_logs")
op.drop_index(op.f("ix_automation_runs_config_id"), table_name="automation_runs")
op.drop_table("automation_runs")
op.drop_index(op.f("ix_automation_configs_character_name"), table_name="automation_configs")
op.drop_table("automation_configs")