Skip to content

refactor(db)!: replace the conditions migration history with one baseline and fix the schema - #455

Merged
Medformatik merged 50 commits into
mainfrom
refactor/conditions-schema-baseline
Nov 24, 2026
Merged

Medformatik merged 50 commits into
mainfrom
refactor/conditions-schema-baseline

Conversation

@Medformatik

Copy link
Copy Markdown
Contributor

What changed and why

No OpenConditions database has to stay upgradeable yet, so this is the last cheap moment to fix the schema before OpenMapX's first production install freezes it. This PR replaces the 107-file migration history with one generated baseline (0000_baseline.sql) plus one custom file (0001_database_objects.sql) for what Drizzle cannot express, and fixes what the pre-install schema review found. The OpenMapX side merged as OpenMapX/openmapx#1079.

  • One baseline, and a drift gate. The migrations are regenerated from the schema code. A new check (scripts/check-drizzle-drift.ts, in the existing CI job and verify:full) passes only when drizzle-kit reports no drift. drizzle-kit 0.31 exits 0 without writing when it would need a prompt, so an exit code alone proves nothing. A test limits the custom file to the statement kinds Drizzle cannot express. Until the first release containing the baseline is installed, schema changes regenerate it. After that they add ordinary incremental migrations (docs/database-migrations.md). The last commit with the old history is 09e880bd.

  • Migration ownership.

    • The history lives in conditions.__drizzle_migrations, and only the ingest processes migrate.
    • contributions-api and federation wait until the database holds their build's schema version (OPENCONDITIONS_SCHEMA_WAIT_TIMEOUT_MS, default 5 minutes).
    • No search path is set in code; operators set search_path = conditions, extensions on the roles.
  • Grants as a contract. conditions.grant_consumer_roles() (SECURITY INVOKER, pinned search path, no PUBLIC execute) grants exactly what is used:

    • OpenMapX's openmapx_tiles_owner gets the four tables and three functions segment_flow needs, so credentials and crowd data stay unreadable to every OpenMapX role;
    • openconditions_contributions gets the 53 table privileges its queries use.

    Ingest calls it after every migrate, so a role created later or restored from a backup gets its grants at the next ingest start.

  • Secrets encrypted at rest.

    • OAuth grant tokens and the issuer and federation private keys are stored as AES-256-GCM ciphertext. Each value is bound to its table, column and row, so it cannot be copied to another row.
    • The key is a new required OPENCONDITIONS_SECRETS_KEY secret. The first ingest process seals a check row with it, and every other service refuses to start with a different key.
  • Crowd data minimisation.

    • reporter.osm_uid, email_lookup_hmac, flagged_count and sub_claim.subject_component_key are dropped.
    • Deleting a reporter cascades to its claims, refusals and quotas, and leaves its evidence keyless.
    • A BEFORE DELETE trigger strips its key from crowd readings, situations, revisions and outbox snapshots on every delete path.
    • The sweep deletes reporters inactive for 12 months (owner decision), ended quotas, spent tokens past their issuer key's validity, and expired federation tombstones.
  • Schema hygiene.

    • Every constraint and index follows one naming convention.
    • Identity columns replace bigserial.
    • The observation tables store fixed-width columns first.
    • CHECKs cover the closed value sets, including the GeoNet coverage order, now in schema code.
    • Redundant indexes are dropped and sweep indexes added.
    • The series read and the whole-series purge honour retention across classes: a read never hides in-window history after a retention change, and a purge never leaves rows behind.
  • Smaller fixes.

    • The OpenLR resolver builds its graph in its own openlr schema instead of conditions.
    • SMN messages are returned in a deterministic order.

Related work

Verification and limits

  • Regeneration: regenerating from the final schema code into an empty folder reproduces 0000_baseline.sql byte for byte, with an equal snapshot apart from id/prevId. The drift gate and the statement-kind test pass.
  • Local suites:
    • pnpm verify:full at the head exits 0: 9778 tests passed, including the container-starting files and the packed OCPI consumer check;
    • the PG18 integration profile: 1824 passed;
    • the OpenLR resolver: 70 pytest tests passed, with ruff clean;
    • pnpm check-credentials and pnpm check:release-information pass.
  • End to end against OpenMapX main (a7e2f9a), run on a production-entrypoint PostGIS with PostGIS in extensions, OpenMapX's roles and its API migrations applied:
    • created both OpenConditions roles with the guide's SQL;
    • ingest migrated as openconditions_ingest, recording two history rows in conditions, applying exactly the contract grants and sealing the key check;
    • contributions-api waited, passed the key check and answered 200, while one started with another key refused to start;
    • Martin 1.16.1, logged in as openmapx_tiles, served a segment_flow tile for a synthetic segment as a 776-byte MVT;
    • openmapx_tiles is refused every direct read of conditions.
  • Image qualification: the image qualifier now applies the migrations and seals the key check itself for the contributions-api and federation images. Its seal step uses only postgres and node:crypto, which the image ships; the first version imported bundled core code and failed with ERR_MODULE_NOT_FOUND inside a real image. A contributions-api image built from this branch (arm64) sealed the row and came up healthy. The full amd64 qualify --image run with Trivy happens for the first time in this PR's build-images job. The script's SHA-256 pin in scripts/check-docker-contexts.mjs changed deliberately; no Dockerfile, workflow or build context changed.
  • Not run:
    • a first migration slow enough to show the unhealthy window;
    • federation and heavy-feeds against the production layout.

Release and upgrade impact

  • Clean install only. A database from an earlier build is not upgraded. Drop the conditions schema or the database first, and also drop the old drizzle.__drizzle_migrations_oc table.
  • New required secret.
    • OPENCONDITIONS_SECRETS_KEY (64 hex characters, openssl rand -hex 32) is required on ingest, ingest-heavy, contributions-api and federation.
    • Generate it once on ingest and copy it to the others; under OpenMapX, that means entering it in each service's Credentials.
    • Keep it in the recovery set. Under OpenMapX, the vault also holds it encrypted with OpenMapX's own secrets key, so both keys belong there.
  • Roles.
    • Create openconditions_ingest, which owns conditions and keeps CREATE on the database at every start. Federation and the heavy-feeds process also connect as this role.
    • Create openconditions_contributions.
    • Give both search_path = conditions, extensions, before ingest first starts.
  • OpenLR: rebuild the resolver graph into openlr.
  • Deployment: deploy together with OpenMapX main from #1079 onwards. The tile grants assume its roles.
  • Visible behaviour:
    • /feeds/status no longer reports unknownStatus;
    • contributions-api and federation report unhealthy for about three minutes while a long first migration runs, and recover once it finishes.

docs/release-notes/database-baseline.md lists every operator step and schema difference. No Changeset: the only public package, @openconditions/ocpi, is untouched.

Deferred, with reasons:

  • COLLATE "C" id columns: drizzle-orm cannot declare a column collation.
  • OC-O1 to OC-O4: performance changes to measure in production first.
  • A blocked reporter's key stays in block_list while the block stands, by design.
  • A hand delete within about 37 days of a situation purge leaves journal entries with the key until the journal prune. The sweep never hits this case, and peers never receive the key.
  • OpenMapX's privacy page does not yet disclose OpenConditions crowd data; that is an OpenMapX follow-up.

Merge as a squash: some intermediate commits are not self-consistent on their own.

Schema differences against the old migration chain

Both schemas were built fresh on PostgreSQL 18.6 with PostGIS 3.6 (ghcr.io/baosystems/postgis:18-3.6, the repository's pg18 test profile image), PostGIS created by the superuser, each migrated as the non-superuser openconditions_ingest holding only CREATE on its database. openconditions_contributions and openmapx_tiles_owner existed before either migrate, so the grants show. The chain is the 107 migrations of 09e880bd applied the way that commit's runMigrations() applied them; the baseline is this branch's built runMigrations() at 8df4e268. The fresh chain dump (pg_dump --schema-only -O -x -n conditions -n drizzle) is byte-identical to B0's chain dump apart from pg_dump's random \restrict token. The comparison below is over the system catalogs (tables, columns, column order, constraints, indexes, functions, triggers, storage parameters, grants), with constraints and indexes matched by their definition, so a rename is reported as a rename and not as a drop and an add.

Counts, chain → baseline: tables 67 → 69, columns 654 → 667, constraints 137 → 157, indexes 148 → 153, functions 24 → 26, triggers 4 → 5, federation_journal seed rows 1 → 1. The 24 functions of the chain are unchanged in the baseline (pg_get_functiondef hashes equal), among them conditions.segment_flow. Every difference traces to a commit on this branch:

Migration history and ownership

  • The history moved from drizzle.__drizzle_migrations_oc to conditions.__drizzle_migrations (drizzle's own table shape: id serial with __drizzle_migrations_pkey, hash, created_at), and only the ingest service migrates. 3ecb3f72
  • The history holds two rows (0000_baseline, 0001_database_objects) instead of 107. 076892bd

Grants

  • New function conditions.grant_consumer_roles() (SECURITY INVOKER, search_path = pg_catalog, pg_temp, EXECUTE revoked from PUBLIC), called by runMigrations() after every migrate. 8dddf975, bada9d1a
  • openmapx_tiles_owner: USAGE on conditions; SELECT on road_segment, segment_speed, source, public_license_policy; EXECUTE on segment_flow, flow_public_licenses, flow_osm_credit (8 grants; the chain granted none). 8dddf975
  • openconditions_contributions: USAGE on conditions and 53 table privileges (SELECT on 27 tables including __drizzle_migrations and secrets_key_check, INSERT on 15, UPDATE on 6, DELETE on 5), no sequence privilege (the chain granted none). 8dddf975, dfebb164 (secrets_key_check), b8e18bcf (no sequence grants)

Secrets

  • oauth_grant.access_token, oauth_grant.refresh_token, issuer_key.private_key and federation_instance_key.private_key are replaced by <column>_ciphertext, <column>_iv and <column>_tag (bytea, nullability as before), each trio with a CHECK that the three are set together, the IV is 12 bytes and the tag 16 (<table>_<column>_check). d0deebf0
  • New table secrets_key_check (id smallint DEFAULT 1 with secrets_key_check_id_check (id = 1) and secrets_key_check_pkey, value_ciphertext/value_iv/value_tag with secrets_key_check_value_check, created_at timestamptz DEFAULT now()). dfebb164

Crowd data

  • Dropped columns: reporter.osm_uid, reporter.email_lookup_hmac, reporter.flagged_count, sub_claim.subject_component_key; the unique key uq_sub_claim_subject_key_type on five columns becomes sub_claim_subject_class_subject_id_key_id_claim_type_key on four. 9c6a5888
  • New foreign keys to reporter(key_id): report_evidence_actor_key_id_fkey (ON DELETE SET NULL), report_refusal_actor_key_id_fkey, sub_claim_key_id_fkey, token_quota_key_id_fkey (ON DELETE CASCADE). 9c6a5888
  • New column spent_token.expires_at timestamptz NOT NULL; the index idx_spent_token_spent_at is replaced by spent_token_expires_at_idx. New sweep indexes reporter_last_active_at_idx and federation_tombstone_expires_at_idx. 9c6a5888 (the sweep that uses them is 67a6704a, the extra day on spent tokens 9cb3774b, with no schema change)
  • New function conditions.reporter_strip_key() and its BEFORE DELETE trigger reporter_strip_key on reporter. 2ca20fd5

Ids and types

  • Identity columns (GENERATED BY DEFAULT AS IDENTITY, sequence names kept) instead of bigserial defaults: federation_outbox.seq, observation_latest.series_id, report_evidence.id, report_refusal.id, source_poll_attempt.id. c887416f
  • jma_budget.day is date instead of text. c887416f
  • segment_observation.confidence is renamed confidence_score (same type). c887416f
  • smn_cap_message.retrieval loses its default '{"legacy": true}'::jsonb. c887416f

CHECKs for closed value sets

  • New: federation_subscription_status_check, federation_tombstone_reason_check, record_binding_direction_mode_check, record_binding_status_check, segment_observation_los_check, segment_speed_confidence_check, segment_speed_los_check. c887416f

Indexes

  • Dropped (a primary key serves them, or nothing reads them): idx_segment_observation_segment, idx_segment_profile_segment, idx_segment_speed_los. b423f4a9
  • idx_situation_crowd_evidence (origin, evidence_state) WHERE origin = 'crowd' becomes situation_evidence_state_crowd_idx (evidence_state) WHERE origin = 'crowd'. b423f4a9
  • New records-sweep indexes: feature_expires_at_idx and offer_expires_at_idx (expires_at WHERE tombstoned_at IS NULL), feature_tombstoned_at_idx and offer_tombstoned_at_idx (tombstoned_at WHERE tombstoned_at IS NOT NULL). b423f4a9
  • The crowd sweep indexes are listed under crowd data above.

Names

  • 98 constraints and 103 indexes keep their definition and change only their name, to <table>_pkey, <table>_<columns>_key, <table>_<column>_fkey, <table>_<columns>_idx and <table>_<what>_check, or a purpose name for partial, collated, expression and over-long indexes (<table>_id_bytes_idx, <table>_id_rights_revoked_idx, observation_latest_value_money_fuel_price_idx, feature_external_ids_idx, observation_latest_series_key, and others). By kind: 28 primary keys, 62 CHECKs (the GeoNet coverage CHECK, written in the chain's last custom migration as geonet_coverage_order, is now geonet_coverage_order_check in the schema code), 7 foreign keys, 1 unique constraint. The two GIN indexes with fastupdate=off keep that parameter under their new names. 4d8471b1 (also the GeoNet CHECK's move from the custom migration into the schema code)

Physical column order

  • 30 tables have a different physical column order with the same columns: contributor_receipt, feature, feature_canonical, federation_instance_key, federation_outbox, federation_peer_key, federation_subscription, federation_tombstone, geonet_coverage, issuer_key, oauth_grant, observation, observation_latest, observation_rollup_daily, observation_rollup_hourly, offer, osm_road, report_evidence, reporter, segment_observation, segment_profile, segment_speed, sensor_baseline, sensor_segment, situation, smn_cap_message, source, source_status, spent_token, sub_claim.
    • 24 of them because a from-empty generation declares columns in schema-code order, where the chain appended later columns at the end. 076892bd
    • observation, observation_latest and observation_rollup_hourly store their fixed-width columns first. 24745e67
    • issuer_key, oauth_grant, federation_instance_key, reporter, spent_token, sub_claim, segment_observation: columns added, dropped or renamed above. d0deebf0, 9c6a5888, c887416f
  • The chain's tables carried 7 dropped-column slots; the baseline has none. 076892bd

Unchanged

  • The 24 functions of the chain (bodies, volatility, security and settings), the four federation_capture triggers, the partitioned observation table's partitioning, the observation_latest storage parameters (toast_tuple_target = 1200, fillfactor = 50, the autovacuum scale factors) and column storage modes, and the federation_journal seed row.
  • Not part of the database schema: the OpenLR resolver's graph moved from conditions.osm_nodes/osm_lines (created at graph build time, never by a migration) to the schema openlr, with an identity line_id. 43fcceb5, 8df4e268 (docstring)
Every rename and the column orders
  • binding_queue: binding_queue_record_class_record_id_effect_id_pk → binding_queue_pkey
  • feature: feature_tombstone_complete → feature_tombstone_check
  • feature: feature_tombstone_reason_enum → feature_tombstone_reason_check
  • feature: feature_access_mode_enum → feature_access_mode_check
  • feature: feature_lifecycle_enum → feature_lifecycle_check
  • feature: feature_origin_enum → feature_origin_check
  • feature: feature_privacy_class_enum → feature_privacy_class_check
  • feature: feature_revision_positive → feature_revision_check
  • feature: feature_temporality_enum → feature_temporality_check
  • feature_component: feature_component_lifecycle_enum → feature_component_lifecycle_check
  • feature_component: feature_component_feature_id_feature_id_fk → feature_component_feature_id_fkey
  • feature_component: feature_component_feature_id_key_pk → feature_component_pkey
  • feature_link: feature_link_ordered → feature_link_order_check
  • feature_link: feature_link_method_enum → feature_link_method_check
  • feature_link: feature_link_status_enum → feature_link_status_check
  • feature_link: feature_link_a_id_b_id_pk → feature_link_pkey
  • feature_revision: feature_revision_feature_id_feature_id_fk → feature_revision_feature_id_fkey
  • feature_revision: feature_revision_feature_id_revision_pk → feature_revision_pkey
  • federation_journal: federation_journal_single_row → federation_journal_singleton_check
  • federation_lapsed_copy: federation_lapsed_copy_record_class_record_id_pk → federation_lapsed_copy_pkey
  • federation_outbox: federation_outbox_delete_shape → federation_outbox_delete_shape_check
  • federation_outbox: federation_outbox_operation_enum → federation_outbox_operation_check
  • federation_outbox: federation_outbox_record_class_enum → federation_outbox_record_class_check
  • federation_peer_key: federation_peer_key_peer_instance_id_key_id_pk → federation_peer_key_pkey
  • federation_source_receipt: federation_source_receipt_peer_instance_id_source_id_pk → federation_source_receipt_pkey
  • federation_subscription: federation_subscription_delivery_mode_enum → federation_subscription_delivery_mode_check
  • federation_tombstone: federation_tombstone_canonical_id_peer_instance_id_pk → federation_tombstone_pkey
  • geonet_coverage: geonet_coverage_order → geonet_coverage_order_check
  • jma_budget: jma_budget_nonnegative → jma_budget_nonnegative_check
  • jma_budget: jma_budget_egress_day_pk → jma_budget_pkey
  • nsw_rfs_clock: nsw_rfs_clock_source_id_incident_id_pk → nsw_rfs_clock_pkey
  • observation: observation_retention_days_nonneg → observation_retention_days_check
  • observation: observation_pk → observation_pkey
  • observation_latest: observation_latest_evidence_state_enum → observation_latest_evidence_state_check
  • observation_latest: observation_latest_access_mode_enum → observation_latest_access_mode_check
  • observation_latest: observation_latest_series → observation_latest_series_key
  • observation_revision: observation_revision_source_id_feature_id_property_pk → observation_revision_pkey
  • observation_rollup_daily: observation_rollup_daily_series_fk → observation_rollup_daily_series_id_fkey
  • observation_rollup_daily: observation_rollup_daily_series_id_day_utc_pk → observation_rollup_daily_pkey
  • observation_rollup_hourly: observation_rollup_hourly_series_fk → observation_rollup_hourly_series_id_fkey
  • observation_rollup_hourly: observation_rollup_hourly_series_id_hour_utc_pk → observation_rollup_hourly_pkey
  • offer: offer_tombstone_complete → offer_tombstone_check
  • offer: offer_tombstone_reason_enum → offer_tombstone_reason_check
  • offer: offer_access_mode_enum → offer_access_mode_check
  • offer: offer_origin_enum → offer_origin_check
  • offer: offer_privacy_class_enum → offer_privacy_class_check
  • offer: offer_revision_positive → offer_revision_check
  • offer: offer_subject_class_enum → offer_subject_class_check
  • offer: offer_temporality_enum → offer_temporality_check
  • offer_revision: offer_revision_offer_id_offer_id_fk → offer_revision_offer_id_fkey
  • offer_revision: offer_revision_offer_id_revision_pk → offer_revision_pkey
  • on_demand_fetch: on_demand_fetch_status_enum → on_demand_fetch_status_check
  • on_demand_fetch: on_demand_fetch_source_id_cell_pk → on_demand_fetch_pkey
  • raw_payload: raw_payload_tier_enum → raw_payload_tier_check
  • raw_payload: raw_payload_pk → raw_payload_pkey
  • record_binding: record_binding_record_class_enum → record_binding_record_class_check
  • record_binding: record_binding_record_class_record_id_effect_id_pk → record_binding_pkey
  • record_relation: record_relation_from_class_enum → record_relation_from_class_check
  • record_relation: record_relation_relation_enum → record_relation_relation_check
  • record_relation: record_relation_to_class_enum → record_relation_to_class_check
  • record_relation: record_relation_pk → record_relation_pkey
  • record_segment: record_segment_record_class_record_id_effect_id_seq_pk → record_segment_pkey
  • report_evidence: report_evidence_kind_enum → report_evidence_evidence_kind_check
  • report_evidence: report_evidence_record_class_enum → report_evidence_record_class_check
  • reporter: reporter_reputation_alpha_positive → reporter_reputation_alpha_check
  • reporter: reporter_reputation_beta_positive → reporter_reputation_beta_check
  • reporter: reporter_status_enum → reporter_status_check
  • road_graph_state: road_graph_state_singleton → road_graph_state_singleton_check
  • segment_observation: segment_observation_segment_id_source_pk → segment_observation_pkey
  • segment_profile: segment_profile_segment_id_dow_tod_hour_pk → segment_profile_pkey
  • sensor_baseline: sensor_baseline_subject_key_dow_bucket_tod_bucket_method_pk → sensor_baseline_pkey
  • situation: situation_evidence_state_enum → situation_evidence_state_check
  • situation: situation_severity_level_range → situation_severity_level_check
  • situation: situation_tombstone_complete → situation_tombstone_check
  • situation: situation_tombstone_reason_enum → situation_tombstone_reason_check
  • situation: situation_access_mode_enum → situation_access_mode_check
  • situation: situation_certainty_enum → situation_certainty_check
  • situation: situation_origin_enum → situation_origin_check
  • situation: situation_privacy_class_enum → situation_privacy_class_check
  • situation: situation_revision_positive → situation_revision_check
  • situation: situation_severity_enum → situation_severity_check
  • situation: situation_temporality_enum → situation_temporality_check
  • situation: situation_validity_status_enum → situation_validity_status_check
  • situation_effect: situation_effect_applicability_enum → situation_effect_applicability_kind_check
  • situation_effect: situation_effect_compliance_enum → situation_effect_compliance_check
  • situation_effect: situation_effect_normalization_enum → situation_effect_normalization_check
  • situation_effect: situation_effect_situation_id_situation_id_fk → situation_effect_situation_id_fkey
  • situation_effect: situation_effect_situation_id_effect_id_pk → situation_effect_pkey
  • situation_revision: situation_revision_situation_id_situation_id_fk → situation_revision_situation_id_fkey
  • situation_revision: situation_revision_situation_id_revision_pk → situation_revision_pkey
  • smn_cap_message: smn_cap_message_source_id_variant_pk → smn_cap_message_pkey
  • source: source_access_mode_enum → source_access_mode_check
  • source: source_tier_enum → source_tier_check
  • source_shrink: source_shrink_scope_enum → source_shrink_scope_check
  • source_shrink: source_shrink_source_id_scope_pk → source_shrink_pkey
  • sub_claim: sub_claim_claim_type_enum → sub_claim_claim_type_check
  • sub_claim: sub_claim_subject_class_enum → sub_claim_subject_class_check
  • token_quota: token_quota_key_id_epoch_pk → token_quota_pkey

Index renames (103)

  • observation: idx_observation_start_brin → observation_phenomenon_start_idx
  • binding_queue: idx_binding_queue_due → binding_queue_next_attempt_at_idx
  • feature: idx_feature_canonical → feature_canonical_id_idx
  • feature: idx_feature_id_bytes → feature_id_bytes_idx
  • feature: idx_feature_rights_revoked → feature_id_rights_revoked_idx
  • feature: idx_feature_kind_lifecycle → feature_kind_lifecycle_idx
  • feature: idx_feature_kind_type → feature_kind_type_idx
  • feature: idx_feature_source → feature_source_id_id_idx
  • feature: idx_feature_external_ids → feature_external_ids_idx
  • feature: idx_feature_geom → feature_geom_idx
  • feature_canonical: idx_feature_canonical_members → feature_canonical_member_ids_idx
  • feature_component: idx_feature_component_kind → feature_component_kind_idx
  • feature_component: idx_feature_component_external_ids → feature_component_external_ids_idx
  • feature_link: idx_feature_link_b → feature_link_b_id_idx
  • feature_revision: idx_feature_revision_recorded → feature_revision_recorded_at_idx
  • federation_lapsed_copy: idx_federation_lapsed_copy_source → federation_lapsed_copy_peer_instance_id_source_id_idx
  • federation_outbox: idx_federation_outbox_created_at → federation_outbox_created_at_idx
  • federation_outbox: idx_federation_outbox_record → federation_outbox_record_class_record_id_seq_idx
  • federation_outbox: idx_federation_outbox_cursor → federation_outbox_txid_seq_idx
  • federation_subscription: idx_federation_subscription_peer → federation_subscription_peer_id_idx
  • observation_latest: idx_observation_latest_effective_brin → observation_latest_effective_from_idx
  • observation_latest: idx_observation_latest_crowd_record → observation_latest_crowd_record_id_idx
  • observation_latest: idx_observation_latest_expires → observation_latest_expires_at_idx
  • observation_latest: idx_observation_latest_component → observation_latest_feature_id_component_key_idx
  • observation_latest: idx_observation_latest_property_text → observation_latest_property_value_text_idx
  • observation_latest: idx_observation_latest_source → observation_latest_source_id_series_id_idx
  • observation_latest: idx_observation_latest_fuel_price → observation_latest_value_money_fuel_price_idx
  • observation_latest: idx_observation_latest_geom → observation_latest_geom_idx
  • observation_rollup_daily: idx_observation_rollup_daily_day → observation_rollup_daily_day_utc_idx
  • observation_rollup_hourly: idx_observation_rollup_hourly_hour → observation_rollup_hourly_hour_utc_idx
  • offer: idx_offer_canonical → offer_canonical_id_idx
  • offer: idx_offer_id_bytes → offer_id_bytes_idx
  • offer: idx_offer_rights_revoked → offer_id_rights_revoked_idx
  • offer: idx_offer_kind_valid_to → offer_kind_valid_to_idx
  • offer: idx_offer_source → offer_source_id_id_idx
  • offer: idx_offer_subject → offer_subject_id_component_key_idx
  • offer: idx_offer_geom → offer_geom_idx
  • offer_revision: idx_offer_revision_recorded → offer_revision_recorded_at_idx
  • osm_road: idx_osm_road_highway → osm_road_highway_idx
  • osm_road: idx_osm_road_ref → osm_road_ref_idx
  • osm_road: idx_osm_road_geom → osm_road_geom_idx
  • raw_payload: idx_raw_payload_base → raw_payload_source_id_base_hash_idx
  • raw_payload: idx_raw_payload_source_time → raw_payload_source_id_first_fetched_at_idx
  • raw_payload: idx_raw_payload_tier_seen → raw_payload_tier_last_seen_at_idx
  • record_binding: idx_record_binding_status → record_binding_status_idx
  • record_relation: idx_record_relation_to → record_relation_to_class_to_id_idx
  • record_segment: idx_record_segment_segment → record_segment_segment_id_idx
  • report_evidence: idx_report_evidence_merged → report_evidence_merged_idx
  • report_evidence: idx_report_evidence_actor → report_evidence_actor_key_id_occurred_at_idx
  • report_evidence: idx_report_evidence_record → report_evidence_record_class_record_id_occurred_at_idx
  • report_refusal: idx_report_refusal_actor → report_refusal_actor_key_id_occurred_at_idx
  • report_refusal: idx_report_refusal_occurred → report_refusal_occurred_at_idx
  • road_segment: idx_road_segment_minzoom → road_segment_min_zoom_idx
  • road_segment: idx_road_segment_way → road_segment_way_id_idx
  • road_segment: idx_road_segment_geom → road_segment_geom_idx
  • sensor_baseline: idx_sensor_baseline_source_bucket → sensor_baseline_source_dow_bucket_tod_bucket_idx
  • sensor_segment: idx_sensor_segment_segment → sensor_segment_segment_id_idx
  • situation: idx_situation_canonical → situation_canonical_id_idx
  • situation: idx_situation_expires → situation_expires_at_idx
  • situation: idx_situation_group → situation_group_id_idx
  • situation: idx_situation_id_bytes → situation_id_bytes_idx
  • situation: idx_situation_rights_revoked → situation_id_rights_revoked_idx
  • situation: idx_situation_kind_type → situation_kind_type_idx
  • situation: idx_situation_source → situation_source_id_id_idx
  • situation: idx_situation_tombstoned → situation_tombstoned_at_idx
  • situation: idx_situation_valid_to → situation_valid_to_idx
  • situation: idx_situation_geom → situation_geom_idx
  • situation_effect: idx_situation_effect_kind_valid_to → situation_effect_kind_valid_to_idx
  • situation_effect: idx_situation_effect_geom → situation_effect_geom_idx
  • situation_revision: idx_situation_revision_recorded → situation_revision_recorded_at_idx
  • source_poll_attempt: idx_source_poll_attempt_time → source_poll_attempt_attempted_at_id_idx
  • source_poll_attempt: idx_source_poll_attempt_source_time → source_poll_attempt_source_attempted_at_idx
  • sub_claim: idx_sub_claim_key → sub_claim_key_id_idx
  • observation: observation_pk → observation_pkey
  • binding_queue: binding_queue_record_class_record_id_effect_id_pk → binding_queue_pkey
  • feature_component: feature_component_feature_id_key_pk → feature_component_pkey
  • feature_link: feature_link_a_id_b_id_pk → feature_link_pkey
  • feature_revision: feature_revision_feature_id_revision_pk → feature_revision_pkey
  • federation_lapsed_copy: federation_lapsed_copy_record_class_record_id_pk → federation_lapsed_copy_pkey
  • federation_peer_key: federation_peer_key_peer_instance_id_key_id_pk → federation_peer_key_pkey
  • federation_source_receipt: federation_source_receipt_peer_instance_id_source_id_pk → federation_source_receipt_pkey
  • federation_subscription: uq_federation_subscription_target → federation_subscription_target_key
  • federation_tombstone: federation_tombstone_canonical_id_peer_instance_id_pk → federation_tombstone_pkey
  • jma_budget: jma_budget_egress_day_pk → jma_budget_pkey
  • nsw_rfs_clock: nsw_rfs_clock_source_id_incident_id_pk → nsw_rfs_clock_pkey
  • observation_latest: observation_latest_series → observation_latest_series_key
  • observation_revision: observation_revision_source_id_feature_id_property_pk → observation_revision_pkey
  • observation_rollup_daily: observation_rollup_daily_series_id_day_utc_pk → observation_rollup_daily_pkey
  • observation_rollup_hourly: observation_rollup_hourly_series_id_hour_utc_pk → observation_rollup_hourly_pkey
  • offer_revision: offer_revision_offer_id_revision_pk → offer_revision_pkey
  • on_demand_fetch: on_demand_fetch_source_id_cell_pk → on_demand_fetch_pkey
  • raw_payload: raw_payload_pk → raw_payload_pkey
  • record_binding: record_binding_record_class_record_id_effect_id_pk → record_binding_pkey
  • record_relation: record_relation_pk → record_relation_pkey
  • record_segment: record_segment_record_class_record_id_effect_id_seq_pk → record_segment_pkey
  • segment_observation: segment_observation_segment_id_source_pk → segment_observation_pkey
  • segment_profile: segment_profile_segment_id_dow_tod_hour_pk → segment_profile_pkey
  • sensor_baseline: sensor_baseline_subject_key_dow_bucket_tod_bucket_method_pk → sensor_baseline_pkey
  • situation_effect: situation_effect_situation_id_effect_id_pk → situation_effect_pkey
  • situation_revision: situation_revision_situation_id_revision_pk → situation_revision_pkey
  • smn_cap_message: smn_cap_message_source_id_variant_pk → smn_cap_message_pkey
  • source_shrink: source_shrink_source_id_scope_pk → source_shrink_pkey
  • token_quota: token_quota_key_id_epoch_pk → token_quota_pkey

Physical column order (30 tables)

  • contributor_receipt
    • chain: id,version,contributors,created_at,provenance
    • baseline: id,version,contributors,provenance,created_at
  • feature
    • chain: id,record,canonical_id,kind,type,subtype,domain,temporality,source_id,source_record_id,origin,access_mode,privacy_class,instance_id,revision,recorded_at,content_hash,fetched_at,expires_at,geom,country,subdivision,tombstone_reason,tombstoned_at,lifecycle,created_at
    • baseline: id,record,canonical_id,kind,type,subtype,domain,temporality,source_id,source_record_id,origin,access_mode,privacy_class,instance_id,revision,recorded_at,content_hash,fetched_at,expires_at,geom,country,subdivision,tombstone_reason,tombstoned_at,created_at,lifecycle
  • feature_canonical
    • chain: canonical_feature_id,survivor_id,member_ids,merged_sources,computed_at,components
    • baseline: canonical_feature_id,survivor_id,member_ids,merged_sources,components,computed_at
  • federation_instance_key
    • chain: key_id,public_key,private_key,multibase,not_before,not_after,created_at,endorsed_by,endorsement,endorsement_proof
    • baseline: key_id,public_key,private_key_ciphertext,private_key_iv,private_key_tag,multibase,not_before,not_after,created_at,endorsed_by,endorsement,endorsement_proof
  • federation_outbox
    • chain: seq,operation,canonical_id,created_at,txid,record_class,record_id,kind,domain,property,priority,snapshot,tombstone_reason,revision
    • baseline: seq,operation,record_class,record_id,canonical_id,kind,domain,property,priority,snapshot,tombstone_reason,revision,created_at,txid
  • federation_peer_key
    • chain: peer_instance_id,key_id,learned_at,anchor
    • baseline: peer_instance_id,key_id,anchor,learned_at
  • federation_subscription
    • chain: id,peer_id,filter,delivery_mode,inbox_url,cursor,priority_only,push_failures,status,created_at,updated_at,revision,expires_at
    • baseline: id,peer_id,filter,delivery_mode,inbox_url,cursor,priority_only,push_failures,revision,status,created_at,updated_at,expires_at
  • federation_tombstone
    • chain: canonical_id,reason,tombstoned_at,expires_at,peer_instance_id
    • baseline: canonical_id,peer_instance_id,reason,tombstoned_at,expires_at
  • geonet_coverage
    • chain: source_id,revisions,covered_from,covered_until
    • baseline: revisions,source_id,covered_from,covered_until
  • issuer_key
    • chain: key_id,public_key,private_key,not_before,not_after
    • baseline: key_id,public_key,private_key_ciphertext,private_key_iv,private_key_tag,not_before,not_after
  • oauth_grant
    • chain: grant_key,refresh_token,refresh_issued_at,access_token,access_expires_at,rejected_at,last_error,last_error_at,updated_at
    • baseline: grant_key,refresh_token_ciphertext,refresh_token_iv,refresh_token_tag,refresh_issued_at,access_token_ciphertext,access_token_iv,access_token_tag,access_expires_at,rejected_at,last_error,last_error_at,updated_at
  • observation
    • chain: series_id,retention_days,phenomenon_start,phenomenon_end,issued_at,result_time,valid_until,fetched_at,recorded_at,temporality,aggregation,value_num,value_money,value_text,value_json,quality,baseline,fetch_id,raw_part,extra
    • baseline: series_id,phenomenon_start,issued_at,fetched_at,recorded_at,phenomenon_end,result_time,valid_until,value_num,fetch_id,retention_days,raw_part,temporality,aggregation,value_money,value_text,value_json,quality,baseline,extra
  • observation_latest
    • chain: series_id,subject_key,property,qualifier_key,source_id,subject_kind,feature_id,component_key,situation_id,geom,template,access_mode,result_type,value_num,value_money,value_text,unit,currency,effective_from,effective_until,since_at,fused_from,expires_at,retention_days,updated_at,evidence_state,confidence_score,corroborations,reading,template_hash,crowd_record_id,fused_sources,fused_public,contributor_receipt_id
    • baseline: series_id,effective_from,since_at,updated_at,effective_until,expires_at,value_num,confidence_score,corroborations,retention_days,fused_public,subject_key,property,qualifier_key,source_id,subject_kind,access_mode,result_type,template_hash,feature_id,component_key,situation_id,crowd_record_id,contributor_receipt_id,value_money,value_text,unit,currency,fused_from,fused_sources,evidence_state,geom,reading,template
  • observation_rollup_daily
    • chain: series_id,day_utc,sample_count,min,max,mean,contributor_receipt_ids,lineage_complete
    • baseline: series_id,day_utc,sample_count,contributor_receipt_ids,lineage_complete,min,max,mean
  • observation_rollup_hourly
    • chain: series_id,hour_utc,sample_count,bins,counts,min,max,mean,contributor_receipt_ids,lineage_complete
    • baseline: series_id,hour_utc,min,max,mean,sample_count,lineage_complete,contributor_receipt_ids,bins,counts
  • offer
    • chain: id,record,canonical_id,kind,type,subtype,domain,temporality,source_id,source_record_id,origin,access_mode,privacy_class,instance_id,revision,recorded_at,content_hash,fetched_at,expires_at,geom,country,subdivision,tombstone_reason,tombstoned_at,subject_class,subject_id,component_key,currency,valid_from,valid_to,min_price,max_price,created_at
    • baseline: id,record,canonical_id,kind,type,subtype,domain,temporality,source_id,source_record_id,origin,access_mode,privacy_class,instance_id,revision,recorded_at,content_hash,fetched_at,expires_at,geom,country,subdivision,tombstone_reason,tombstoned_at,created_at,subject_class,subject_id,component_key,currency,valid_from,valid_to,min_price,max_price
  • osm_road
    • chain: way_id,geom,highway,oneway,ref,name,maxspeed_kph,region,imported_at,import_config_hash,import_provenance,oneway_reversed
    • baseline: way_id,geom,highway,oneway,oneway_reversed,ref,name,maxspeed_kph,region,import_config_hash,import_provenance,imported_at
  • report_evidence
    • chain: id,evidence_kind,actor_key_id,source_id,occurred_at,details,record_class,record_id,component_key
    • baseline: id,record_class,record_id,component_key,evidence_kind,actor_key_id,source_id,occurred_at,details
  • reporter
    • chain: key_id,pub_jwk,osm_uid,email_lookup_hmac,reputation_alpha,reputation_beta,corroborated_count,flagged_count,trust_signal,entitlement_expires_at,status,created_at,last_active_at
    • baseline: key_id,pub_jwk,reputation_alpha,reputation_beta,corroborated_count,trust_signal,entitlement_expires_at,status,created_at,last_active_at
  • segment_observation
    • chain: segment_id,source,source_tier,current_kph,free_flow_kph,speed_ratio,los,confidence,sample_count,observed_at,expires_at,native_field_sources,field_sources,field_contributors,field_lineage_complete,permission_licenses
    • baseline: segment_id,source,source_tier,current_kph,free_flow_kph,speed_ratio,los,confidence_score,sample_count,native_field_sources,field_sources,field_contributors,field_lineage_complete,permission_licenses,observed_at,expires_at
  • segment_profile
    • chain: segment_id,dow,tod_hour,speed_kph,sample_count,computed_at,contributing,contributor_receipt_ids,lineage_complete,permission_licenses
    • baseline: segment_id,dow,tod_hour,speed_kph,sample_count,contributor_receipt_ids,lineage_complete,permission_licenses,contributing,computed_at
  • segment_speed
    • chain: segment_id,current_kph,free_flow_kph,speed_ratio,los,confidence,source_tier,contributing,is_estimated,observed_at,updated_at,native_field_sources,field_sources,field_contributors,field_lineage_complete,permission_licenses
    • baseline: segment_id,current_kph,free_flow_kph,speed_ratio,los,confidence,source_tier,contributing,is_estimated,native_field_sources,field_sources,field_contributors,field_lineage_complete,permission_licenses,observed_at,updated_at
  • sensor_baseline
    • chain: source,dow_bucket,tod_bucket,free_flow_kph,method,sample_count,computed_at,subject_key,contributor_receipt_ids,lineage_complete,permission_licenses,contributing
    • baseline: subject_key,source,dow_bucket,tod_bucket,free_flow_kph,method,contributor_receipt_ids,lineage_complete,permission_licenses,contributing,sample_count,computed_at
  • sensor_segment
    • chain: segment_id,fraction,offset_m,bearing_deg,matched_at,subject_key
    • baseline: subject_key,segment_id,fraction,offset_m,bearing_deg,matched_at
  • situation
    • chain: id,record,canonical_id,kind,type,subtype,domain,temporality,source_id,source_record_id,origin,access_mode,privacy_class,instance_id,revision,recorded_at,content_hash,fetched_at,expires_at,geom,country,subdivision,tombstone_reason,tombstoned_at,severity,severity_level,certainty,planned,validity_status,valid_from,valid_to,group_id,evidence_state,confidence_score,routing_eligible,corroborations,flagged_at,created_at
    • baseline: id,record,canonical_id,kind,type,subtype,domain,temporality,source_id,source_record_id,origin,access_mode,privacy_class,instance_id,revision,recorded_at,content_hash,fetched_at,expires_at,geom,country,subdivision,tombstone_reason,tombstoned_at,created_at,severity,severity_level,certainty,planned,validity_status,valid_from,valid_to,group_id,evidence_state,confidence_score,routing_eligible,corroborations,flagged_at
  • smn_cap_message
    • chain: source_id,identifier,body,retain_until,variant,retrieval
    • baseline: source_id,identifier,variant,retrieval,body,retain_until
  • source
    • chain: id,domain,format,access_mode,tier,country,subdivision,operator,license,license_url,attribution,rights,cadence_sec,freshness_window_sec,raw_retention,extras_allow,extras_federate,lane_numbering,parent_source_id,policy_ids,selection_state,active,updated_at,product,restricted,restricted_since,fusion_restricted,fusion_tier,fusion_licenses,federation_restricted,federation_pending,credit_name,credit_url,credit_notice
    • baseline: id,domain,format,product,access_mode,tier,country,subdivision,operator,license,license_url,attribution,credit_name,credit_url,credit_notice,rights,restricted,restricted_since,fusion_restricted,fusion_tier,fusion_licenses,federation_restricted,federation_pending,cadence_sec,freshness_window_sec,raw_retention,extras_allow,extras_federate,lane_numbering,parent_source_id,policy_ids,selection_state,active,updated_at
  • source_status
    • chain: source,last_attempt_at,last_success_at,freshness_window_sec,last_row_count,last_error,updated_at,last_network_success_at,freshness_deadline,last_publication_at,publication_revision,last_outcome,active_event_count,last_inserted,last_updated,last_deleted,last_rejected,last_duration_ms,consecutive_failures,last_error_at,raw_hot_evicted_at,source_published_at
    • baseline: source,last_attempt_at,last_success_at,last_network_success_at,freshness_deadline,source_published_at,last_publication_at,publication_revision,last_outcome,freshness_window_sec,last_row_count,active_event_count,last_inserted,last_updated,last_deleted,last_rejected,last_duration_ms,consecutive_failures,last_error,last_error_at,raw_hot_evicted_at,updated_at
  • spent_token
    • chain: token_hash,purpose,spent_at
    • baseline: token_hash,purpose,spent_at,expires_at
  • sub_claim
    • chain: id,subject_id,claim_type,key_id,reason,geom,signature,created_at,subject_class,subject_component_key
    • baseline: id,subject_class,subject_id,claim_type,key_id,reason,geom,signature,created_at

…line

The 107 migrations up to 0106 become two files: a baseline generated by
drizzle-kit from the schema code, and a custom migration with what
drizzle-kit cannot express (the partitioned observation table and its
index, the observation_latest storage settings, the functions, the four
federation capture triggers, the federation journal's first epoch and,
until the schema code declares it, the geonet coverage CHECK). Applied as
a role holding only CREATE on the database, it gives the same conditions
schema as the old chain on PostgreSQL 16 and 18, apart from physical
column order. Data fixes the old migrations applied to existing rows are
not carried over.

A test limits the custom file to the statement kinds drizzle-kit cannot
express, and a fresh-migrate test checks the functions, triggers and
storage settings. Tests that replayed old migration files are removed.
pnpm check:migrations fails when the schema code and the migrations
disagree, and CI runs it.

BREAKING CHANGE: a database created by an earlier build is not upgraded
and has to be recreated. The old history is in Git up to 09e880b.
drizzle-kit exits 0 and writes nothing when it refuses a prompt without a
terminal and when the schema code fails to load, so an exit code and an
unchanged folder passed real drift. The gate now runs as a script that
requires "Everything's fine" and "No schema changes, nothing to migrate",
fails on any error or TTY line, a nonzero exit, a timeout, or a changed
migrations folder. The docs also name the temporary geonet CHECK in the
custom file and no longer treat the baseline's foreign-key ALTERs as a
sign of a non-empty folder.
…migration

A dollar sign in a comment can pair with another and hide a statement
between them, and the seed row matched any multi-row insert. Comments
with a dollar sign are refused, the seed row must be the one exact
statement and appear once, and committed cases pin what the check must
refuse and accept. A test title now says what it checks: a second
migrate keeps a later deployed function.
…ngest

The migrator records applied migrations in conditions.__drizzle_migrations
instead of drizzle.__drizzle_migrations_oc, so the ingest role needs to own
only conditions, the history never mixes with another Drizzle project's in a
shared database, and dropping conditions drops its history with it.

Only the ingest service migrates. The contributions and federation services
wait at boot with waitForSchemaVersion until the history reaches the latest
journal entry their build ships, or a later one, and stop with what they
expected and found after OPENCONDITIONS_SCHEMA_WAIT_TIMEOUT_MS (default five
minutes). Image qualification applies the source's migrations to the fixture
database for those two images, as they no longer migrate it themselves.
The OAuth grant tokens, the token issuer's private keys and the federation
instance keys were stored in clear, so every database dump and backup held
them. They are now sealed with AES-256-GCM under OPENCONDITIONS_SECRETS_KEY
(64 hex characters, read from OPENCONDITIONS_SECRETS_KEY_FILE under OpenMapX),
each value bound to its table, column and row. The ciphertext, IV and tag
columns replace the plaintext ones, with CHECKs on the IV and tag lengths.

Ingest, its feed-auth command, the contributions API and an enabled
federation service refuse to start without the key, with a malformed one, or
with one that cannot decrypt a stored secret, naming the table and row. Token
redemption and the published issuer key list read only public keys.

The manifests declare the key as a vault secret, and the README says how to
generate and keep it and what losing it costs.
… key

The container qualification starts each image with OPENCONDITIONS_SECRETS_KEY, which the services now refuse to start without. The context check pins the reviewed script's digest, so it follows that one-line change.
…vice sealed

After migrating, the ingest service seals a fixed value with its secrets key
in a new one-row table, conditions.secrets_key_check, once. The contributions
API and an enabled federation service wait for that row after the schema
version and refuse to start when their key does not open it; the feed-auth
command checks it too. The ingest service opens its stored grants before it
seals the row, so a wrong key never seals it. The contributions role is
granted SELECT on the new table.

Only the ingest service's key field says how to generate the key; the
heavy-feeds ingest, contributions and federation fields say to copy it, and no
field claims the key never reaches the database. The container qualification
seals the check row with the image's own code before the contributions API
starts, and the context check pins the changed script.

The federation actor document reads public keys only, the federation settings
narrow on enabled instead of asserting the key, the ingest start is a tested
function, and the env-or-file credential reader lives once, in core.
The OpenConditions tables never hold the key, but under OpenMapX its vault keeps it in the same database, encrypted with OpenMapX's own secrets key: a backup is safe for these secrets only while that key file stays out of it, and both keys belong in the recovery set. The key is generated once for the ingest service and copied to the others, the quick start reuses one key file, and starting over after a lost or compromised key lists every step and consequence.
The reporter table loses osm_uid, email_lookup_hmac and flagged_count, and
sub_claim loses subject_component_key, which nothing wrote or read. The
vote uniqueness becomes sub_claim_subject_class_subject_id_key_id_claim_type_key.
The OSM-auth verifier result no longer carries an account id, since there
is nowhere to keep one.

sub_claim, report_refusal and token_quota reference reporter ON DELETE
CASCADE and report_evidence ON DELETE SET NULL, so deleting a reporter
removes its votes, refusals and quotas and keeps its evidence keyless.
Peer deliveries and external resolutions already write a NULL actor.
Corroboration credits no key when the merged report's reporter is gone.

spent_token gains expires_at, set at redemption from the not_after of the
issuer key the token names (now for a token that names no stored key), so
expired rows can be pruned. The retention sweep's expiry and activity
columns are indexed.
…g in the sweep

The records sweep now deletes a reporter whose last_active_at and
entitlement_expires_at both lie more than 12 months back (both columns are
NOT NULL), token quotas of an ended UTC day, spent tokens past their
expiry and federation erasure facts past theirs. The reporter's foreign
keys take its votes, refusals and quotas with it and clear its key from
its evidence.

Each delete runs in batches of 500 rows per statement and skips rows
another transaction holds, so the sweep holds no long lock and never waits
on an enrolment; a batch that meets a lock past lock_timeout counts as busy.
A BEFORE DELETE trigger on conditions.reporter removes provenance.reporter
from the reporter's latest crowd readings, crowd situations, their
revisions and their federation journal entries, in the deleting
transaction. The sweep, a delete by hand and any later path therefore
erase the key alike. The whole reporter object goes, since a reporter
without its key is not a valid record and a record without one is.

The rows are found through the reporter's evidence, which still names the
key before the delete's SET NULL runs, then through the crowd record,
primary-key and journal indexes; no index on the readings is added, so
flow updates stay heap-only. The function pins its search path and runs
as the deleting role: only the ingest service, the owner, deletes
reporters.
…kens a day longer

A reporter batch now takes the crowd's advisory lock, then its reporter
rows FOR UPDATE SKIP LOCKED, then deletes them: the order landings take
them in, so the two cannot deadlock and a landing cannot write a key back
while the delete strips it. A lock held past lock_timeout leaves the batch
to the next sweep.

Spent tokens are deleted a day after their expiry instead of at it, so a
contributions service whose clock runs behind the ingest service's cannot
redeem a token whose row is already gone. The sweep's doc comment no
longer says every delete runs under a source's lock.
…weep

segment_observation and segment_profile lose their segment_id indexes, which the primary keys already serve, and segment_speed loses its level-of-service index, which nothing reads. The crowd evidence index keys on evidence_state alone, as origin is constant inside it. feature and offer get the expiry and tombstone indexes the five-minute sweep looks up.
…for closed value sets

The five bigserial columns become identity columns generated by default; their sequences keep their names, so the contributions grants are unchanged. jma_budget.day is a date, segment_observation.confidence becomes confidence_score (it is a number, unlike segment_speed.confidence), and smn_cap_message.retrieval loses a default that could only mislabel a new row. Level of service, segment speed confidence, binding status and direction, subscription status and erasure reason each get a CHECK of their values.
…umns

Primary keys are <table>_pkey, uniques <table>_<columns>_key, foreign keys <table>_<column>_fkey, indexes <table>_<columns>_idx and checks <table>_<what>_check. Foreign keys move from .references() to named foreignKey() and composite primary keys get explicit names. The geonet coverage CHECK is declared in the schema code as geonet_coverage_order_check, so the custom migration no longer carries it and its statement-kind test allows no CHECK at all.
observation, observation_latest and observation_rollup_hourly put their 8-byte columns first, then the narrower fixed-width ones and the variable-length ones last, so no row pays alignment padding between them. The observation primary key is unchanged, and every writer and reader of these tables names its columns.
… in the catalog

The schema conventions tests read the catalog: every constraint and index named after its table and columns or listed as named for its purpose, no serial default and identity on the five ids, a CHECK naming every value of each closed set, fixed-width columns first in the observation tables, no index a unique constraint already serves, every foreign key column indexed, the records sweep's indexes, and the jma_budget, segment_observation and smn_cap_message column types.
The series read and the deletion of a re-homed crowd series' history name the series' retention_days, which the history is partitioned by, so each reads one class's partitions instead of all. A reading stored under a class the property no longer keeps is past the series' retention: it is not read, and its own partition's retention drops it.
…can leave a reporter's key

The release note's compatibility section lists how the schema differs from the old migration chain, by category, instead of claiming it equals it. The crowd limitations say that a hand delete within about 37 days of a situation purge can leave journal entries with the key until the daily journal prune, which the sweep never hits.
…ts class

The series read matched readings on the series' current retention class, so after a property's retention changed it hid every reading written under the earlier class, even inside both retentions. It now reads every class and serves a reading while it is inside the property's current raw retention; each reading's own class still drops it with its partition. The supersession of a change-only reading also continues across a class change.
… class

Deleting a re-homed crowd series' history matched only its current retention class and skipped a series without one, which left readings under any other class behind, those of the keep-everything class for good. It deletes by series alone again.
…ery one

record_binding.status now has a CHECK of BindingStatus, so a status the metrics reader does not know cannot be stored. STATUS_KEYS is typed over every current status, which the compiler keeps complete, and the unknownStatus counter that could no longer count anything is gone from the reader, its test and the binding docs.
…eed none

The ids it inserts are identity columns, whose default takes the next value with the table's INSERT privilege alone, so the USAGE grants on their four sequences widened the role's exact privileges for nothing. The contributions flows test still runs every insert with the smaller set.
…se-named indexes

The release note listed the GeoNet coverage CHECK among the new ones, though the old schema had it under another name, and its naming bullet left out the indexes named for their purpose. A segment speed comment names the renamed confidence_score column.
@Medformatik Medformatik self-assigned this Nov 24, 2026
@Medformatik
Medformatik merged commit 707bb68 into main Nov 24, 2026
22 checks passed
@Medformatik
Medformatik deleted the refactor/conditions-schema-baseline branch November 24, 2026 08:51
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant