feat(backend): Verbesserung der Initialisierung von Haustypen in initializeFalukantTypes.js
- Hinzufügen einer Fehlerbehandlung für fehlende minimale Adelstitel während der Erstellung von Haustypen. - Verbesserung der Konsolenausgaben zur besseren Nachverfolgbarkeit von Warnungen und Fehlern. - Sicherstellung, dass nur gültige Haustypen erstellt werden, um Dateninkonsistenzen zu vermeiden.
This commit is contained in:
@@ -799,15 +799,32 @@ export const initializePromotionalGiftMoodLinks = async () => {
|
||||
|
||||
export const initializeFalukantHouseTypes = async () => {
|
||||
for (const ht of houseTypes) {
|
||||
const [record, created] = await HouseType.findOrCreate({
|
||||
where: { labelTr: ht.abbr },
|
||||
defaults: {
|
||||
cost: ht.cost,
|
||||
imageUrl: null,
|
||||
position: ht.position,
|
||||
minimumNobleTitle: await TitleOfNobility.findOne({ where: { labelTr: ht.minimumTitle } }).then(title => title.id),
|
||||
try {
|
||||
// Finde den minimalen Adelstitel
|
||||
const minimumTitle = await TitleOfNobility.findOne({ where: { labelTr: ht.minimumTitle } });
|
||||
|
||||
if (!minimumTitle) {
|
||||
console.warn(`⚠️ Warnung: Titel '${ht.minimumTitle}' für Haustyp '${ht.abbr}' nicht gefunden. Überspringe...`);
|
||||
continue;
|
||||
}
|
||||
});
|
||||
|
||||
const [record, created] = await HouseType.findOrCreate({
|
||||
where: { labelTr: ht.abbr },
|
||||
defaults: {
|
||||
cost: ht.cost,
|
||||
imageUrl: null,
|
||||
position: ht.position,
|
||||
minimumNobleTitle: minimumTitle.id,
|
||||
}
|
||||
});
|
||||
|
||||
if (created) {
|
||||
console.log(`✅ Haustyp '${ht.abbr}' erstellt`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ Fehler beim Erstellen des Haustyps '${ht.abbr}':`, error.message);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user