Phase 5 — ETL Migration Script & Isolation Tests #110
Labels
No labels
architecture
backend
bug
ci
config
database
docker
documentation
duplicate
enhancement
frontend
help wanted
invalid
issue-25
issue-26
issue-42
issue-65
issue-67
issue-82
migrations
p0-critical
p1-high
p2-medium
p3-low
performance
quality
question
security
state-management
testing
timezone
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
fastie81/honbu-manager#110
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Issue: Phase 5 — ETL Migration Script & Isolation Tests
Type: Architecture / Refactoring
Priority: High
Epic: Epic: Database-per-Club Multi-Tenancy Split & Data Migration
Status: Backlog
1. Context & Purpose
To migrate running production data safely without loss, we need a robust ETL (Extract, Transform, Load) script. We also require a suite of E2E isolation tests to guarantee that a user authenticated to Club A cannot access data in Club B.
2. Technical Specification
2.1. Standalone ETL Script (
etl_migrate.py)Create scripts/etl_migrate.py:
run_migrations(CENTRAL_MIGRATIONS)).users,clubs,user_club_assignments,oauth2_config,api_tokens.password_hashvalues.clubstable:CREATE DATABASE honbu_club_<id>.honbu_club_<id>and applyrun_migrations(CLUB_MIGRATIONS).members,families,family_guardians,attendance,belt_levels,gradings,class_schedules,notes_history,form_configurations,content_items,content_club_approvals.familiesbeforemembersbeforeattendance).SELECT setval(pg_get_serial_sequence('table_name', 'id'), coalesce(max(id), 1), max(id) IS NOT NULL) FROM table_name;This prevents subsequent primary key collision errors on insert.
database_namecolumn in the Central database tohonbu_club_<id>.--dry-run: Performs queries and shows count reports but executes no database creation or insert commands.--verify-only: Executes verification check on existing databases.--club-id <id>: Migrates a single club (useful for quick testing on staging).2.2. Tenant Isolation Tests (
test_tenant_isolation.py)Create tests/e2e/test_tenant_isolation.py:
with route_to_club(1):) returns exactly zero members from Club 2.403 Forbiddenif it attempts to query/modify endpoints with parameters referencing Club 2.get_users_by_clubdoesn't leak any user records across clubs.2.3. complete docker-compose.test.yml Setup (Issue #93)
docker-compose.test.ymlby adding the PostgreSQL database service configuration matching the CI pipeline setup.3. Verification Plan
3.1. Automated Verification
3.2. Manual Verification
python scripts/etl_migrate.py --dry-runon staging. Check that the console logs print a detailed row-count projection and verify that no new databases are created.Part of Epic #105