Create MonthContext table
Description
Add MonthContext as the single source of truth for reporting periods. Each row represents one unique reporting month/year and stores editable calendar/service context used by every department report.
Technical Details
Current schema stores reporting_month directly on several tables or computes a synthetic monthlyReportId in the frontend. The diagram expects all department reports and KPIs to reference MonthContext.
Schema Changes
Create month_context with:
id SERIAL PRIMARY KEY
year INTEGER NOT NULL
month INTEGER NOT NULL
days_closed INTEGER DEFAULT 0
route44_weekdays_ran INTEGER
route44_weekends_ran INTEGER
shake_up_occurred BOOLEAN DEFAULT false
holiday_saturdays INTEGER
holiday_sundays INTEGER
weekdays INTEGER
fridays INTEGER
saturdays INTEGER
sundays INTEGER
shakeup_weekdays INTEGER
shakeup_fridays INTEGER
shakeup_saturdays INTEGER
shakeup_sundays INTEGER
shakeup_holiday_saturdays INTEGER
shakeup_holiday_sundays INTEGER
shakeup_days_closed INTEGER
shakeup_route44_weekdays INTEGER
shakeup_route44_saturdays INTEGER
- Unique constraint on
(year, month)
Frontend Tasks
Replace raw reporting-month-only workflows with a month picker flow that creates or looks up a MonthContext row and lets users review/edit the generated calendar fields.
Acceptance Criteria
- Users cannot create duplicate
MonthContext rows for the same month/year.
- Calendar-derived fields are stored and editable.
- Department report creation can resolve a valid
month_context_id.
Dependencies
None.
Create MonthContext table
Description
Add
MonthContextas the single source of truth for reporting periods. Each row represents one unique reporting month/year and stores editable calendar/service context used by every department report.Technical Details
Current schema stores
reporting_monthdirectly on several tables or computes a syntheticmonthlyReportIdin the frontend. The diagram expects all department reports and KPIs to referenceMonthContext.Schema Changes
Create
month_contextwith:id SERIAL PRIMARY KEYyear INTEGER NOT NULLmonth INTEGER NOT NULLdays_closed INTEGER DEFAULT 0route44_weekdays_ran INTEGERroute44_weekends_ran INTEGERshake_up_occurred BOOLEAN DEFAULT falseholiday_saturdays INTEGERholiday_sundays INTEGERweekdays INTEGERfridays INTEGERsaturdays INTEGERsundays INTEGERshakeup_weekdays INTEGERshakeup_fridays INTEGERshakeup_saturdays INTEGERshakeup_sundays INTEGERshakeup_holiday_saturdays INTEGERshakeup_holiday_sundays INTEGERshakeup_days_closed INTEGERshakeup_route44_weekdays INTEGERshakeup_route44_saturdays INTEGER(year, month)Frontend Tasks
Replace raw reporting-month-only workflows with a month picker flow that creates or looks up a
MonthContextrow and lets users review/edit the generated calendar fields.Acceptance Criteria
MonthContextrows for the same month/year.month_context_id.Dependencies
None.