fix(backend): Anpassung der Indexfelder in mehreren Modelldateien auf snake_case
- Umbenennung der Indexfelder von camelCase auf snake_case in verschiedenen Modelldateien zur Verbesserung der Konsistenz mit den Datenbankkonventionen. - Verbesserung der Regex-Logik zur Erkennung und Ersetzung von Index-Definitionen und Feld-Arrays im Skript zur automatischen Korrektur.
This commit is contained in:
@@ -23,20 +23,24 @@ function fixModelFile(filePath) {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let modified = false;
|
||||
|
||||
// Suche nach Index-Definitionen
|
||||
// Suche nach Index-Definitionen - verbesserte Regex
|
||||
const indexRegex = /indexes:\s*\[([\s\S]*?)\]/g;
|
||||
let match;
|
||||
|
||||
while ((match = indexRegex.exec(content)) !== null) {
|
||||
const indexesSection = match[1];
|
||||
|
||||
// Suche nach fields-Arrays
|
||||
// Suche nach fields-Arrays - verbesserte Regex
|
||||
const fieldsRegex = /fields:\s*\[([^\]]+)\]/g;
|
||||
let fieldsMatch;
|
||||
|
||||
while ((fieldsMatch = fieldsRegex.exec(indexesSection)) !== null) {
|
||||
const fieldsString = fieldsMatch[1];
|
||||
const fields = fieldsString.split(',').map(f => f.trim().replace(/['"]/g, ''));
|
||||
// Verbesserte Feld-Extraktion
|
||||
const fields = fieldsString.split(',').map(f => {
|
||||
const cleaned = f.trim().replace(/['"]/g, '');
|
||||
return cleaned;
|
||||
}).filter(f => f.length > 0);
|
||||
|
||||
// Konvertiere jedes Feld von camelCase zu snake_case
|
||||
const correctedFields = fields.map(field => {
|
||||
@@ -51,10 +55,15 @@ function fixModelFile(filePath) {
|
||||
return corrected;
|
||||
});
|
||||
|
||||
// Ersetze die fields-Array
|
||||
// Ersetze die fields-Array - verbesserte Ersetzung
|
||||
const oldFieldsString = `fields: [${fields.map(f => `'${f}'`).join(', ')}]`;
|
||||
const newFieldsString = `fields: [${correctedFields.map(f => `'${f}'`).join(', ')}]`;
|
||||
|
||||
// Debug-Ausgabe
|
||||
console.log(` 📍 Datei: ${path.basename(filePath)}`);
|
||||
console.log(` 🔍 Gefunden: ${oldFieldsString}`);
|
||||
console.log(` ✅ Ersetzt: ${newFieldsString}`);
|
||||
|
||||
content = content.replace(oldFieldsString, newFieldsString);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user