Files
Mitgliederverwaltung/.plans/issue-18-members-migration.md
T
2026-04-07 21:46:41 +02:00

73 lines
3.5 KiB
Markdown

# Plan: Issue #18 — Set up DB migrations for members table
## Summary
Create a Nextcloud OCP migration class that sets up the `oc_mv_members` table with all columns specified in the issue and requirements section 5.2. The migration follows Nextcloud's migration framework using `\OCP\Migration\SimpleMigrationStep` and Doctrine DBAL schema. Foreign key columns for `stufe_id` and `family_id` are created as nullable integer columns (FK constraints will be added when those tables are created in issues #30 and #27 respectively).
## Implementation Steps
### Step 1: Create Migration Class
- File: `lib/Migration/Version000001Date20260407000000.php`
- Namespace: `OCA\Mitgliederverwaltung\Migration`
- Extends: `SimpleMigrationStep`
- Method: `changeSchema(IOutput $output, Closure $schemaClosure, array $options)`
### Step 2: Define Table Schema — `oc_mv_members`
Columns (from issue #18 specification):
| Column | Type | Constraints |
|--------|------|------------|
| `id` | bigint | PK, autoincrement, unsigned |
| `vorname` | string(255) | NOT NULL |
| `nachname` | string(255) | NOT NULL |
| `geburtsdatum` | date | NOT NULL |
| `geschlecht` | string(20) | nullable |
| `rolle` | string(30) | NOT NULL, default 'mitglied' |
| `stufe_id` | bigint | nullable, unsigned (FK to oc_mv_stufen, added later) |
| `eintritt` | date | NOT NULL |
| `austritt` | date | nullable |
| `status` | string(20) | NOT NULL, default 'aktiv' |
| `allergien_encrypted` | text | nullable |
| `notizen` | text | nullable |
| `zusatz_notizen` | text | nullable |
| `kv_typ` | string(20) | nullable |
| `kv_name` | string(255) | nullable |
| `family_id` | bigint | nullable, unsigned (FK to oc_mv_families, added later) |
| `frozen_fee_rate` | decimal(10,2) | nullable |
| `calendar_event_uri` | string(512) | nullable |
| `contact_vcard_uri` | string(512) | nullable |
| `created_at` | datetime | NOT NULL, default CURRENT_TIMESTAMP |
| `updated_at` | datetime | NOT NULL, default CURRENT_TIMESTAMP |
| `deleted_at` | datetime | nullable |
### Step 3: Add Indexes
- Index on `status` (frequent filtering)
- Index on `family_id` (joins)
- Index on `stufe_id` (joins)
- Index on `nachname` (sorting/searching)
- Index on `deleted_at` (soft-delete queries)
- Composite index on `status, deleted_at` (common query pattern: active non-deleted members)
### Step 4: Verify Migration Structure
- Ensure the class is properly namespaced and autoloadable via PSR-4
- Ensure the table name uses Nextcloud's table prefix convention (just use `mv_members` — Nextcloud adds `oc_` prefix)
## Acceptance Criteria Checklist
1. [ ] Migration file exists at `lib/Migration/Version000001Date20260407000000.php`
2. [ ] Class extends `SimpleMigrationStep` and implements `changeSchema`
3. [ ] Table `mv_members` is created with all 20 columns from the spec
4. [ ] Column types match the specification (string for enums, bigint for FKs, decimal for fee rate, etc.)
5. [ ] `id` is primary key, autoincrement, unsigned bigint
6. [ ] NOT NULL constraints applied to: vorname, nachname, geburtsdatum, rolle, eintritt, status, created_at, updated_at
7. [ ] Nullable columns: geschlecht, stufe_id, austritt, allergien_encrypted, notizen, zusatz_notizen, kv_typ, kv_name, family_id, frozen_fee_rate, calendar_event_uri, contact_vcard_uri, deleted_at
8. [ ] Default values set for: rolle='mitglied', status='aktiv'
9. [ ] Appropriate indexes are created
10. [ ] PHP syntax is valid (no parse errors)
11. [ ] File follows Nextcloud migration conventions (namespace, class name pattern)
12. [ ] Migration is idempotent (checks if table exists before creating)