Files
gh-christianlouis-docuelevate/migrations/versions/039_add_classification_rules.py
T
copilot-swe-agent[bot] e518bce922 fix: merge main branch and renumber migration 037→040
Resolve all merge conflicts between our automation feature branch and
current main (v0.163.0, 920 commits ahead).

Conflicts resolved:
- app/api/__init__.py: add automation_router alongside main's new routers
  (classification_rules, qr_auth, sessions, system_reset)
- app/config.py: add main's new settings (dropbox_use_global_credentials,
  factory_reset_on_startup, enable_factory_reset)
- app/models.py: add main's new models (ClassificationRuleModel, UserSession,
  QRLoginChallenge, SharePoint integration type)
- app/utils/settings_service.py: merge automation_hooks_enabled with main's
  new metadata entries
- docs/API.md: merge automation API docs with main's classification rules docs
- docs/ConfigurationGuide.md: add factory reset settings
- tests/conftest.py: import both AutomationHook and new main models

Migration renumbered:
- 037_add_automation_hooks → 040_add_automation_hooks
- down_revision: 039_add_classification_rules (was 036_add_document_translation_fields)
- Chain: 036 → 037 → 038 → 039 → 040 (automation hooks)

For all non-automation files with conflicts, main's version was taken since
our branch did not modify those files (conflicts were from a stale prior merge).

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/cb62f012-3b69-4415-835e-3857ce3e9f45
2026-03-20 23:54:04 +00:00

47 lines
2.0 KiB
Python

"""Add classification_rules table for custom document classification rules.
Revision ID: 039_add_classification_rules
Revises: 038_add_api_token_expires_at
Create Date: 2026-03-17
"""
from typing import Union
import sqlalchemy as sa
from alembic import op
revision: str = "039_add_classification_rules"
down_revision: Union[str, None] = "038_add_api_token_expires_at"
depends_on: Union[str, None] = None
def upgrade() -> None:
"""Create classification_rules table."""
op.create_table(
"classification_rules",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("owner_id", sa.String(), nullable=True),
sa.Column("name", sa.String(255), nullable=False),
sa.Column("category", sa.String(100), nullable=False),
sa.Column("rule_type", sa.String(50), nullable=False),
sa.Column("pattern", sa.String(1000), nullable=False),
sa.Column("priority", sa.Integer(), nullable=False, server_default="0"),
sa.Column("case_sensitive", sa.Boolean(), nullable=False, server_default="0"),
sa.Column("enabled", sa.Boolean(), nullable=False, server_default="1"),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("owner_id", "name", name="uq_classification_rules_owner_name"),
)
op.create_index("ix_classification_rules_id", "classification_rules", ["id"])
op.create_index("ix_classification_rules_owner_id", "classification_rules", ["owner_id"])
op.create_index("ix_classification_rules_category", "classification_rules", ["category"])
def downgrade() -> None:
"""Drop classification_rules table."""
op.drop_index("ix_classification_rules_category", "classification_rules")
op.drop_index("ix_classification_rules_owner_id", "classification_rules")
op.drop_index("ix_classification_rules_id", "classification_rules")
op.drop_table("classification_rules")