Skip to content

Fix migration file naming mismatch and add validation tooling - #169

Merged
itshypax merged 6 commits into
mainfrom
copilot/fix-db-migration-error
Nov 26, 2025
Merged

Fix migration file naming mismatch and add validation tooling#169
itshypax merged 6 commits into
mainfrom
copilot/fix-db-migration-error

Conversation

Copilot AI commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

Migration alter_intra_notifications_type_04112025.php failed because the filename implied a non-existent table intra_notifications_type, while the SQL altered the actual intra_notifications table.

The migration system extracts table names from filenames via regex (create|alter)_(.+?)_\d{8}\.php and validates table existence before running ALTER operations (lines 414-430 in database-init.php).

Changes

  • Renamed alter_intra_notifications_type_04112025.phpalter_intra_notifications_04112025.php
  • Updated migration reference in setup/database-init.php line 317

Before: File extracts to intra_notifications_type → validation fails
After: File extracts to intra_notifications → validation passes

The migration now correctly validates against the existing intra_notifications table (created by create_intra_notifications_03112025.php) and modifies the type column to accept system as a notification type.

Preventive Measures Added

Following analysis of all 58 migration files (which found 0 additional critical issues), this PR adds preventive tooling:

Migration Validation Tool (setup/validate-migrations.php)

  • Automatically validates all CREATE and ALTER migration files
  • Detects naming mismatches before they cause failures
  • Handles multi-table migrations and special cases
  • Can be run via composer db:validate

Documentation (setup/MIGRATIONS.md)

  • Comprehensive guide on migration naming conventions
  • Best practices for creating new migrations
  • Troubleshooting guide for common issues
  • Examples of correct and incorrect naming patterns

Analysis Results

  • ✅ All CREATE migrations (23 files) correctly named
  • ✅ All ALTER migrations (9 files) correctly named
  • ✅ All UPDATE migrations (5 files) correctly named
  • The original issue was an isolated case with no similar problems found

These tools will help prevent similar naming issues in the future by catching them during development rather than at deployment.

Original prompt

This section details on the original issue you should resolve

<issue_title>Weiterhin Probleme mit DB Migration </issue_title>
<issue_description>Ein Problem gelöst, ein neues da:

▶️ Führe aus [alter]: alter_intra_notifications_type_04112025.php
❌ Fehlgeschlagen: alter_intra_notifications_type_04112025.php
Fehler: Cannot alter table 'intra_notifications_type' - table does not exist

⚠️ Kritischer Fehler bei alter-Migration. Abbruch.
Bitte überprüfen Sie:

  1. Datenbankberechtigungen (CREATE, ALTER, INDEX Rechte)
  2. MySQL/MariaDB Version und Kompatibilität
  3. Verfügbarer Speicherplatz
  4. MySQL-Fehlerlog für detaillierte Fehlermeldungen

Script @php setup/database-init.php handling the db:migrate event returned with error code 1
Script @db:migrate was called via post-install-cmd</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues with database migration for intra_notifications_type Fix migration file naming mismatch for intra_notifications table Nov 24, 2025
Copilot AI requested a review from itshypax November 24, 2025 01:56
@itshypax

Copy link
Copy Markdown
Collaborator

@copilot Kannst du auch die anderen Dateien nach ähnlichen Fehlern oder Problemen durchsuchen und diese präventiv beheben?

Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>

Copilot AI commented Nov 24, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Kannst du auch die anderen Dateien nach ähnlichen Fehlern oder Problemen durchsuchen und diese präventiv beheben?

Ich habe eine umfassende Analyse aller 58 Migrationsdateien durchgeführt. Gute Nachricht: Keine kritischen Probleme gefunden!

Alle CREATE (23) und ALTER (9) Migrationen sind korrekt benannt. Der ursprüngliche alter_intra_notifications_type Fehler war ein Einzelfall.

Präventive Maßnahmen implementiert:

  1. Validierungs-Tool (setup/validate-migrations.php)

    • Prüft automatisch alle CREATE/ALTER Migrationen
    • Erkennt Naming-Fehler bevor sie Probleme verursachen
    • Nutzung: composer db:validate
  2. Dokumentation (setup/MIGRATIONS.md)

    • Naming Conventions erklärt
    • Best Practices & Troubleshooting Guide
    • Beispiele für korrekte/fehlerhafte Benennung

Diese Tools helfen, zukünftige Naming-Probleme zu vermeiden.

Commit: 4982429

Copilot AI and others added 2 commits November 24, 2025 18:24
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Copilot AI changed the title Fix migration file naming mismatch for intra_notifications table Fix migration file naming mismatch and add validation tooling Nov 24, 2025
@itshypax
itshypax marked this pull request as ready for review November 26, 2025 00:30
@itshypax
itshypax merged commit 64172dd into main Nov 26, 2025
1 check passed
@itshypax
itshypax deleted the copilot/fix-db-migration-error branch November 26, 2025 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weiterhin Probleme mit DB Migration

2 participants