Add groups + group_members models and migration
docs/planning/social.md US-5 (task 13). Models + Alembic migration only, per the sibling-dependency boundary with the Groups API task. - groups: id, name, description, owner_id (FK users, ON DELETE SET NULL -- a group is a durable multi-member community, so it and its full roster survive the owner deleting their account; the API task handles surfacing an ownerless group for reassignment). - group_members: group_id/user_id (both FK, ON DELETE CASCADE -- pure join-table rows with no meaning without either side), role (owner/admin/member native enum, default member), joined_at, unique constraint on (group_id, user_id). - User gets owned_groups / group_memberships relationships. - tests/conftest.py TEST_TABLES updated for truncation between tests. - New tests/test_group_models.py: role assignment, unique-membership rejection, group-delete cascade, member-delete cascade, and owner-delete SET NULL survival -- all verified against real Postgres. Verified: upgrade/downgrade/upgrade round-trip, \d-inspected schema matches spec (FKs, cascade behavior, unique constraint, indexes), full backend suite 166 passed / 0 regressions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y2FESCaMXeJpC9gSctiEeD
This commit is contained in:
@@ -50,6 +50,10 @@ TEST_TABLES = (
|
||||
# reached by cascading a truncate of messages/conversations; list it
|
||||
# explicitly along with the rest for clarity/consistency.
|
||||
"message_reports", "messages", "conversation_participants", "conversations",
|
||||
# Groups (app/models/groups.py). groups.owner_id is ON DELETE SET NULL
|
||||
# (not CASCADE, deliberately -- see groups.py), so it wouldn't be reached
|
||||
# by cascading a truncate of users; list it explicitly for clarity too.
|
||||
"group_members", "groups",
|
||||
"sessions", "refresh_tokens", "users",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user