Add region relationship to ChurchOffice model: Establish associations between ChurchOffice and RegionData, allowing for better organization of church offices by region. Enhance logging in getChurchOverview method for improved debugging and error handling.

This commit is contained in:
Torsten Schulz (local)
2026-01-28 16:45:40 +01:00
parent a8b76bc21a
commit afc36161ed
2 changed files with 70 additions and 45 deletions

View File

@@ -913,6 +913,16 @@ export default function setupAssociations() {
as: 'supervisor'
});
// Region relationship
ChurchOffice.belongsTo(RegionData, {
foreignKey: 'regionId',
as: 'region'
});
RegionData.hasMany(ChurchOffice, {
foreignKey: 'regionId',
as: 'churchOffices'
});
// Applications for church office
ChurchApplication.belongsTo(ChurchOfficeType, {
foreignKey: 'officeTypeId',