"""Seed the ``finance.fiscal_year_start_month`` platform setting (= April). Revision ID: 329 Revises: 328 Create Date: 2026-06-25 The finance budget engine, run-rate forecast, and every "this fiscal year" aggregation now read the fiscal-year start month from this platform setting (see ``app.core.fiscal_year``). The org's fiscal year starts in **April**, so seed the row at ``4``. Absent the row the code already defaults to 4, but seeding it makes the value explicit, admin-visible (the platform-settings UI groups by the ``finance.`` prefix), and editable without a code change. Idempotency ----------- INSERT only when the key is absent (``ON DUPLICATE KEY UPDATE key=key`` no-op). Re-running never clobbers an admin-edited value. """ from __future__ import annotations import sqlalchemy as sa from alembic import op revision = "329" down_revision = "328" branch_labels = None depends_on = None _KEY = "finance.fiscal_year_start_month" def upgrade() -> None: op.execute( sa.text( "INSERT INTO platform_settings (`key`, `value`, `description`, " "`created_at`, `updated_at`) " "VALUES (:k, CAST(:v AS JSON), :d, NOW(), NOW()) " "ON DUPLICATE KEY UPDATE `key` = `key`" ).bindparams( k=_KEY, v="4", d="Fiscal-year start month (1-12); 4 = April. Re-windows all " "finance budget / forecast reads.", ) ) def downgrade() -> None: op.execute( sa.text("DELETE FROM platform_settings WHERE `key` = :k").bindparams(k=_KEY) )