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 203d95ca50
commit 23b053a35f
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',