fix: complete user-delete FK lockstep across PG and SQLite schemas #1
Reference in New Issue
Block a user
Delete Branch "fix/user-delete-fk-schema-lockstep"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The prior user-deletion work updated the PG schema and a live-PG migration
but left the canonical schema definitions inconsistent, breaking user
deletion on fresh PG installs and on all SQLite dev installs.
only user FK missing it; fresh PG installs could not delete an authoring
user).
(drop NOT NULL, add ON DELETE SET NULL): project_context.updated_by,
context_files.updated_by, change_requests.submitted_by,
reviews.reviewer_id, audit_log.user_id.
ON DELETE SET NULL on audit_log.user_id is an UPDATE the trigger aborted,
so deleting any user who had ever logged in failed. This mirrors schema.sql,
which dropped the equivalent PG triggers in fc1a2f5; append-only is enforced
at the application layer (db.py only INSERTs into audit_log).
(Exception masked sqlite3.IntegrityError); only FK violations map to the
soft "user_has_references" response, everything else propagates. PG
rollback-on-any-error (shared-connection cascade fix) is preserved.
dev DBs must be recreated to pick up these changes.
names, column expressions) to API callers; it is logged instead.
of re-deriving it from the constraint name.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com