Files
Mitgliederverwaltung/.plans/done/issue-19-addresses-phones-emails-migration.md
T
shahondin1624 b29a268b1d Restructure .plans/ into done/ and open/ subdirectories
- Move completed plan files to .plans/done/
- Move 18 open plan files to .plans/open/
- Update .gitignore to exclude .verified_plans temp file
- Verified all 18 open plans still describe unimplemented issues
2026-04-28 20:30:55 +02:00

2.4 KiB

Plan: Issue #19 - DB migrations for addresses, phones, emails

Summary

Create a new Nextcloud migration class (Version000002Date20260407000001) that creates three tables: oc_mv_addresses, oc_mv_phones, and oc_mv_emails. Each table has a foreign key reference to oc_mv_members(id) with CASCADE delete. Follow the exact same pattern as the existing Version000001Date20260407000000.php migration.

Steps

  1. Create lib/Migration/Version000002Date20260407000001.php
  2. Implement changeSchema() method that creates three tables:
    • mv_addresses: id, member_id (FK), label, strasse, plz, ort, land, is_primary
    • mv_phones: id, member_id (FK), label, number_e164
    • mv_emails: id, member_id (FK), label, email
  3. Add appropriate indexes on member_id for each table
  4. Each table guards with hasTable() check before creating

Schema Details

mv_addresses

Column Type Constraints
id BIGINT PK, autoincrement, unsigned
member_id BIGINT NOT NULL, unsigned, FK -> mv_members(id) CASCADE
label STRING(100) nullable (e.g. "Hauptadresse", "Zweitadresse")
strasse STRING(255) NOT NULL
plz STRING(10) NOT NULL
ort STRING(255) NOT NULL
land STRING(100) default 'Deutschland'
is_primary BOOLEAN NOT NULL, default false

mv_phones

Column Type Constraints
id BIGINT PK, autoincrement, unsigned
member_id BIGINT NOT NULL, unsigned, FK -> mv_members(id) CASCADE
label STRING(100) nullable (e.g. "Mobil", "Festnetz")
number_e164 STRING(20) NOT NULL

mv_emails

Column Type Constraints
id BIGINT PK, autoincrement, unsigned
member_id BIGINT NOT NULL, unsigned, FK -> mv_members(id) CASCADE
label STRING(100) nullable (e.g. "Privat", "Arbeit")
email STRING(255) NOT NULL

AC Verification Checklist

  1. Migration file exists at lib/Migration/Version000002Date20260407000001.php
  2. All three tables (mv_addresses, mv_phones, mv_emails) are created
  3. All columns match the schema in the issue
  4. Foreign keys reference mv_members(id) with CASCADE delete
  5. Tables have proper indexes on member_id
  6. Migration class follows Nextcloud SimpleMigrationStep pattern
  7. Each table creation is guarded with hasTable() check
  8. PHP syntax is valid