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 () => {
|
export const initializeFalukantHouseTypes = async () => {
|
||||||
for (const ht of houseTypes) {
|
for (const ht of houseTypes) {
|
||||||
const [record, created] = await HouseType.findOrCreate({
|
try {
|
||||||
where: { labelTr: ht.abbr },
|
// Finde den minimalen Adelstitel
|
||||||
defaults: {
|
const minimumTitle = await TitleOfNobility.findOne({ where: { labelTr: ht.minimumTitle } });
|
||||||
cost: ht.cost,
|
|
||||||
imageUrl: null,
|
if (!minimumTitle) {
|
||||||
position: ht.position,
|
console.warn(`⚠️ Warnung: Titel '${ht.minimumTitle}' für Haustyp '${ht.abbr}' nicht gefunden. Überspringe...`);
|
||||||
minimumNobleTitle: await TitleOfNobility.findOne({ where: { labelTr: ht.minimumTitle } }).then(title => title.id),
|
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