-- Align the auth-account table name with the AppUser entity (issue #418).
-- The historical mismatch (table 'users' alongside table 'persons') misleads
-- schema-first readers into assuming the two are related. Renaming the table to
-- 'app_users' makes the deliberate split between auth accounts and historical
-- persons explicit at the schema layer.
--
-- Scope: the table itself, the users_groups join table, and the three FK
-- columns whose name is literally 'user_id'. Semantic FK columns
-- (audit_log.actor_id, notifications.recipient_id, document_versions.editor_id,
-- document_comments.author_id, transcription_blocks.created_by/updated_by,
-- transcription_block_versions.changed_by, document_annotations.created_by,
-- ocr_training_runs.triggered_by, invite_tokens.created_by, geschichten.author_id)
-- keep their names — the role they describe is the documentation, not the type.

ALTER TABLE users          RENAME TO app_users;

ALTER TABLE users_groups   RENAME TO app_users_groups;
ALTER TABLE app_users_groups        RENAME COLUMN user_id TO app_user_id;

ALTER TABLE comment_mentions        RENAME COLUMN user_id TO app_user_id;
ALTER TABLE password_reset_tokens   RENAME COLUMN user_id TO app_user_id;
