fix(backend): rename users table to app_users
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m43s
CI / OCR Service Tests (pull_request) Successful in 39s
CI / Backend Unit Tests (pull_request) Failing after 3m15s
CI / Unit & Component Tests (push) Failing after 3m37s
CI / OCR Service Tests (push) Successful in 41s
CI / Backend Unit Tests (push) Failing after 3m2s

Aligns the auth-account table name with the AppUser entity. The historical
mismatch (table 'users' alongside table 'persons') misled schema-first readers
into assuming the two were related; renaming 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 was literally 'user_id'. Semantic FK columns (audit_log.actor_id,
notifications.recipient_id, document_versions.editor_id, etc.) keep their
names — the role they describe is the documentation, not the type.

Closes #418. Unblocks #407 (REFACTOR-1).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit was merged in pull request #419.
This commit is contained in:
Marcel
2026-05-04 21:44:21 +02:00
parent d4f666e981
commit eedf5e3ac1
10 changed files with 117 additions and 23 deletions

View File

@@ -0,0 +1,21 @@
-- 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;