from sqlalchemy import Connection as Connection
from sqlalchemy.orm import Mapper as Mapper

from ..contexts import get_user_id as get_user_id
from ..utils import (
    current_timestamp as current_timestamp,
    try_updatable as try_updatable,
)

class UpdateMixin:
    """Mixin for models with update tracking.

    AUTOMATIC BEHAVIOR on any model creation or change:
    - last_modified: Set to current timestamp in SYSTEM_TIMEZONE
    - last_modified_by: Set from ctx_user_id context

    To control automatic updates:
    ```python
    disable_on_update()
    enable_on_update()
    ```

    The actual columns are defined in the model itself
    based on what exists in the database schema.

    A model using this mixin may have one or more of:
    - last_modified: When the record was last modified (including creation)
    - last_modified_by: Who made the last modification (including creation)
    """

    def touch(self) -> None:
        """Manually update last_modified fields."""

def disable_on_update() -> None:
    """Disable automatic updates of last_modified fields."""

def enable_on_update() -> None:
    """Enable automatic updates of last_modified fields."""
