feat(db): Add deletion_log table and cleanup indexes
Phase 1 Complete - Database Schema - Add deletion_log table for audit trail (no personal data) - Add performance indexes for cleanup queries: - idx_groups_approved - idx_groups_cleanup (approved, upload_date) - idx_deletion_log_deleted_at (DESC) - idx_deletion_log_year - Table structure: group_id, year, image_count, upload_date, deleted_at, deletion_reason, total_file_size Tasks completed: ✅ 1.1, ✅ 1.2
This commit is contained in:
parent
852890fca6
commit
4f58b04a0f
|
|
@ -24,7 +24,7 @@ This project extends the original [Image-Uploader by vallezw](https://github.com
|
||||||
- **Slideshow Display**: Image descriptions shown as overlays during slideshow presentation
|
- **Slideshow Display**: Image descriptions shown as overlays during slideshow presentation
|
||||||
- **Public Display**: Descriptions visible in public group views and galleries
|
- **Public Display**: Descriptions visible in public group views and galleries
|
||||||
|
|
||||||
### Previous Features (January 2025)
|
### Previous Features (October 2025)
|
||||||
- **Drag-and-Drop Image Reordering**: Admins can now reorder images using intuitive drag-and-drop
|
- **Drag-and-Drop Image Reordering**: Admins can now reorder images using intuitive drag-and-drop
|
||||||
- **Touch-Friendly Interface**: Mobile-optimized controls with always-visible drag handles
|
- **Touch-Friendly Interface**: Mobile-optimized controls with always-visible drag handles
|
||||||
- **Slideshow Integration**: Custom image order automatically applies to slideshow mode
|
- **Slideshow Integration**: Custom image order automatically applies to slideshow mode
|
||||||
|
|
|
||||||
|
|
@ -115,12 +115,31 @@ class DatabaseManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Erstelle Deletion Log Tabelle
|
||||||
|
await this.run(`
|
||||||
|
CREATE TABLE IF NOT EXISTS deletion_log (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
group_id TEXT NOT NULL,
|
||||||
|
year INTEGER NOT NULL,
|
||||||
|
image_count INTEGER NOT NULL,
|
||||||
|
upload_date DATETIME NOT NULL,
|
||||||
|
deleted_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deletion_reason TEXT DEFAULT 'auto_cleanup_7days',
|
||||||
|
total_file_size INTEGER
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
console.log('✓ Deletion Log Tabelle erstellt');
|
||||||
|
|
||||||
// Erstelle Indizes
|
// Erstelle Indizes
|
||||||
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_group_id ON groups(group_id)');
|
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_group_id ON groups(group_id)');
|
||||||
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_year ON groups(year)');
|
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_year ON groups(year)');
|
||||||
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_upload_date ON groups(upload_date)');
|
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_upload_date ON groups(upload_date)');
|
||||||
|
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_approved ON groups(approved)');
|
||||||
|
await this.run('CREATE INDEX IF NOT EXISTS idx_groups_cleanup ON groups(approved, upload_date)');
|
||||||
await this.run('CREATE INDEX IF NOT EXISTS idx_images_group_id ON images(group_id)');
|
await this.run('CREATE INDEX IF NOT EXISTS idx_images_group_id ON images(group_id)');
|
||||||
await this.run('CREATE INDEX IF NOT EXISTS idx_images_upload_order ON images(upload_order)');
|
await this.run('CREATE INDEX IF NOT EXISTS idx_images_upload_order ON images(upload_order)');
|
||||||
|
await this.run('CREATE INDEX IF NOT EXISTS idx_deletion_log_deleted_at ON deletion_log(deleted_at DESC)');
|
||||||
|
await this.run('CREATE INDEX IF NOT EXISTS idx_deletion_log_year ON deletion_log(year)');
|
||||||
console.log('✓ Indizes erstellt');
|
console.log('✓ Indizes erstellt');
|
||||||
|
|
||||||
// Erstelle Trigger
|
// Erstelle Trigger
|
||||||
|
|
|
||||||
|
|
@ -354,30 +354,29 @@ export const getDeletionStatistics = async () => {
|
||||||
|
|
||||||
### Phase 1: Database & Schema (Aufgaben 1-2)
|
### Phase 1: Database & Schema (Aufgaben 1-2)
|
||||||
|
|
||||||
#### Aufgabe 1: Database Schema für approved-Spalte prüfen ✅ **BEREITS VORHANDEN**
|
#### Aufgabe 1: Database Schema für approved-Spalte prüfen ✅ **ABGESCHLOSSEN**
|
||||||
- [x] ~~Migration Script erstellen~~ **NICHT NÖTIG** - approved-Spalte existiert bereits!
|
- [x] ~~Migration Script erstellen~~ **NICHT NÖTIG** - approved-Spalte existiert bereits!
|
||||||
- [x] ~~approved-Spalte zu groups-Tabelle hinzufügen~~ **BEREITS VORHANDEN** (DatabaseManager.js, Zeile 60)
|
- [x] ~~approved-Spalte zu groups-Tabelle hinzufügen~~ **BEREITS VORHANDEN** (DatabaseManager.js, Zeile 60)
|
||||||
- [x] ~~Migration in DatabaseManager integrieren~~ **BEREITS VORHANDEN** (Zeile 67-75)
|
- [x] ~~Migration in DatabaseManager integrieren~~ **BEREITS VORHANDEN** (Zeile 67-75)
|
||||||
- [x] ~~Indizes erstellen~~ **Performance-Index für cleanup hinzufügen**
|
- [x] Index für Cleanup-Abfragen hinzugefügt: `idx_groups_cleanup` und `idx_groups_approved`
|
||||||
- [ ] Index für Cleanup-Abfragen hinzufügen: `CREATE INDEX IF NOT EXISTS idx_groups_cleanup ON groups(approved, upload_date)`
|
|
||||||
|
|
||||||
**Akzeptanzkriterien:**
|
**Akzeptanzkriterien:**
|
||||||
- ✅ Spalte `approved` existiert bereits mit DEFAULT FALSE
|
- ✅ Spalte `approved` existiert bereits mit DEFAULT FALSE
|
||||||
- ✅ Migration läuft automatisch bei jedem Server-Start (DatabaseManager.js)
|
- ✅ Migration läuft automatisch bei jedem Server-Start (DatabaseManager.js)
|
||||||
- ⏳ Zusätzlicher Index für Cleanup-Performance hinzufügen
|
- ✅ Cleanup-Indizes hinzugefügt (approved, upload_date)
|
||||||
- ✅ Keine Datenverluste - Bestehende Gruppen haben `approved = false`
|
- ✅ Keine Datenverluste - Bestehende Gruppen haben `approved = false`
|
||||||
|
|
||||||
#### Aufgabe 2: Deletion Log Tabelle erstellen
|
#### Aufgabe 2: Deletion Log Tabelle erstellen ✅ **ABGESCHLOSSEN**
|
||||||
- [ ] `deletion_log` Tabelle im Schema definieren
|
- [x] `deletion_log` Tabelle im Schema definiert (DatabaseManager.js)
|
||||||
- [ ] Indizes für schnelle Abfragen erstellen
|
- [x] Indizes für schnelle Abfragen erstellt (`deleted_at DESC`, `year`)
|
||||||
- [ ] Migration Script erstellen
|
- [x] Struktur ohne personenbezogene Daten
|
||||||
- [ ] Validierung der Tabellenstruktur
|
- [x] Validierung der Tabellenstruktur
|
||||||
|
|
||||||
**Akzeptanzkriterien:**
|
**Akzeptanzkriterien:**
|
||||||
- Tabelle enthält alle definierten Spalten
|
- ✅ Tabelle enthält alle definierten Spalten (group_id, year, image_count, upload_date, deleted_at, deletion_reason, total_file_size)
|
||||||
- Keine personenbezogenen Daten im Schema
|
- ✅ Keine personenbezogenen Daten im Schema
|
||||||
- Indizes für `deleted_at` und `year` existieren
|
- ✅ Indizes für `deleted_at` und `year` existieren
|
||||||
- Struktur ist optimal für Abfragen (letzte 10, alle, Statistiken)
|
- ✅ Struktur ist optimal für Abfragen (letzte 10, alle, Statistiken)
|
||||||
|
|
||||||
### Phase 2: Backend Core Logic (Aufgaben 3-5)
|
### Phase 2: Backend Core Logic (Aufgaben 3-5)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user