Missing Model Imports (Fixed):

1. ams_history - AMS sensor history table
  2. pending_upload - Virtual printer pending uploads table
  3. slot_preset - AMS slot preset mappings table

  Missing Column Migrations (Added earlier in session):
  1. print_queue.target_model - Model-based queue assignment
  2. print_queue.required_filament_types - Filament type requirements
  3. print_queue.waiting_reason - Why job is waiting
  4. printers.nozzle_count - Dual-extruder detection
  5. printers.print_hours_offset - Baseline hours adjustment
  6. notification_providers.on_queue_job_added - Queue job added notification
  7. notification_providers.on_queue_job_assigned - Queue job assigned notification
  8. notification_providers.on_queue_job_started - Queue job started notification
  9. notification_providers.on_queue_job_waiting - Queue job waiting notification
  10. notification_providers.on_queue_job_skipped - Queue job skipped notification
  11. notification_providers.on_queue_job_failed - Queue job failed notification
  12. notification_providers.on_queue_completed - Queue completed notification

  Tables verified as OK (no migrations needed):
  - api_keys - No new columns since v0.1.5
  - external_links - No new columns since v0.1.5
  - library_files/folders - New in v0.1.6, created fresh
  - github_backup_config/logs - New in v0.1.6, created fresh
  - project_bom_items - New in v0.1.6, created fresh
  - groups/user_groups - New in v0.1.6, created fresh
This commit is contained in:
maziggy
2026-01-31 18:15:38 +01:00
parent 6ff394d016
commit 7d1f98e407
+35
View File
@@ -34,6 +34,7 @@ async def get_db() -> AsyncSession:
async def init_db():
# Import models to register them with SQLAlchemy
from backend.app.models import ( # noqa: F401
ams_history,
api_key,
archive,
external_link,
@@ -45,11 +46,13 @@ async def init_db():
maintenance,
notification,
notification_template,
pending_upload,
print_queue,
printer,
project,
project_bom,
settings,
slot_preset,
smart_plug,
user,
)
@@ -959,6 +962,38 @@ async def run_migrations(conn):
except Exception:
pass
# Migration: Add queue notification event columns to notification_providers
try:
await conn.execute(text("ALTER TABLE notification_providers ADD COLUMN on_queue_job_added BOOLEAN DEFAULT 0"))
except Exception:
pass
try:
await conn.execute(
text("ALTER TABLE notification_providers ADD COLUMN on_queue_job_assigned BOOLEAN DEFAULT 0")
)
except Exception:
pass
try:
await conn.execute(text("ALTER TABLE notification_providers ADD COLUMN on_queue_job_started BOOLEAN DEFAULT 0"))
except Exception:
pass
try:
await conn.execute(text("ALTER TABLE notification_providers ADD COLUMN on_queue_job_waiting BOOLEAN DEFAULT 1"))
except Exception:
pass
try:
await conn.execute(text("ALTER TABLE notification_providers ADD COLUMN on_queue_job_skipped BOOLEAN DEFAULT 1"))
except Exception:
pass
try:
await conn.execute(text("ALTER TABLE notification_providers ADD COLUMN on_queue_job_failed BOOLEAN DEFAULT 1"))
except Exception:
pass
try:
await conn.execute(text("ALTER TABLE notification_providers ADD COLUMN on_queue_completed BOOLEAN DEFAULT 0"))
except Exception:
pass
async def seed_notification_templates():
"""Seed default notification templates if they don't exist."""