3.5 KiB
3.5 KiB
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 addsoc_prefix)
Acceptance Criteria Checklist
- Migration file exists at
lib/Migration/Version000001Date20260407000000.php - Class extends
SimpleMigrationStepand implementschangeSchema - Table
mv_membersis created with all 20 columns from the spec - Column types match the specification (string for enums, bigint for FKs, decimal for fee rate, etc.)
idis primary key, autoincrement, unsigned bigint- NOT NULL constraints applied to: vorname, nachname, geburtsdatum, rolle, eintritt, status, created_at, updated_at
- 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
- Default values set for: rolle='mitglied', status='aktiv'
- Appropriate indexes are created
- PHP syntax is valid (no parse errors)
- File follows Nextcloud migration conventions (namespace, class name pattern)
- Migration is idempotent (checks if table exists before creating)