fix: merge main, address code review feedback for security fix PR #816
- Merge origin/main into branch (resolve conflict in integrations_dashboard.html) - Add defensive JSON parsing with try/except for integration.config - Wrap tester() call in try/except to prevent 500 errors from bad config - Add i18n key integrations.connection_test_failed_fallback in en.json - Reference i18n key in template JS fallback message - Update SECURITY_AUDIT.md: add fix date (2026-03-23), update doc date - Remove accidental revert.sh file - Fix missing MagicMock/patch imports in test file - Add tests for invalid JSON config and tester exception error paths Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/daebb70e-059a-4601-8864-88eef49f99cf
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
"""Add document_comments and document_annotations tables.
|
||||
|
||||
Revision ID: 041_add_document_comments_and_annotations
|
||||
Revises: 040_add_automation_hooks
|
||||
Create Date: 2026-03-21
|
||||
|
||||
"""
|
||||
|
||||
from typing import Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "041_add_document_comments_and_annotations"
|
||||
down_revision: Union[str, None] = "040_add_automation_hooks"
|
||||
depends_on: Union[str, None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Add document_comments and document_annotations tables."""
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
existing_tables = set(inspector.get_table_names())
|
||||
|
||||
if "document_comments" not in existing_tables:
|
||||
op.create_table(
|
||||
"document_comments",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("file_id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.String(), nullable=False),
|
||||
sa.Column("parent_id", sa.Integer(), nullable=True),
|
||||
sa.Column("body", sa.Text(), nullable=False),
|
||||
sa.Column("mentions", sa.Text(), nullable=True),
|
||||
sa.Column("is_resolved", sa.Boolean(), nullable=False, server_default="0"),
|
||||
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(), onupdate=sa.func.now()),
|
||||
sa.ForeignKeyConstraint(["file_id"], ["files.id"]),
|
||||
sa.ForeignKeyConstraint(["parent_id"], ["document_comments.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("ix_document_comments_id", "document_comments", ["id"])
|
||||
op.create_index("ix_document_comments_file_id", "document_comments", ["file_id"])
|
||||
op.create_index("ix_document_comments_user_id", "document_comments", ["user_id"])
|
||||
op.create_index("ix_document_comments_parent_id", "document_comments", ["parent_id"])
|
||||
|
||||
if "document_annotations" not in existing_tables:
|
||||
op.create_table(
|
||||
"document_annotations",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("file_id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.String(), nullable=False),
|
||||
sa.Column("page", sa.Integer(), nullable=False),
|
||||
sa.Column("x", sa.Float(), nullable=False),
|
||||
sa.Column("y", sa.Float(), nullable=False),
|
||||
sa.Column("width", sa.Float(), nullable=False),
|
||||
sa.Column("height", sa.Float(), nullable=False),
|
||||
sa.Column("content", sa.Text(), nullable=False),
|
||||
sa.Column("annotation_type", sa.String(50), nullable=False, server_default="note"),
|
||||
sa.Column("color", sa.String(20), nullable=True),
|
||||
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(), onupdate=sa.func.now()),
|
||||
sa.ForeignKeyConstraint(["file_id"], ["files.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("ix_document_annotations_id", "document_annotations", ["id"])
|
||||
op.create_index("ix_document_annotations_file_id", "document_annotations", ["file_id"])
|
||||
op.create_index("ix_document_annotations_user_id", "document_annotations", ["user_id"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Drop document_comments and document_annotations tables."""
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
existing_tables = set(inspector.get_table_names())
|
||||
|
||||
if "document_annotations" in existing_tables:
|
||||
op.drop_index("ix_document_annotations_user_id", "document_annotations")
|
||||
op.drop_index("ix_document_annotations_file_id", "document_annotations")
|
||||
op.drop_index("ix_document_annotations_id", "document_annotations")
|
||||
op.drop_table("document_annotations")
|
||||
|
||||
if "document_comments" in existing_tables:
|
||||
op.drop_index("ix_document_comments_parent_id", "document_comments")
|
||||
op.drop_index("ix_document_comments_user_id", "document_comments")
|
||||
op.drop_index("ix_document_comments_file_id", "document_comments")
|
||||
op.drop_index("ix_document_comments_id", "document_comments")
|
||||
op.drop_table("document_comments")
|
||||
Reference in New Issue
Block a user