Skip to content

Schema drift between production databases; migrator has no integrity check #37

Description

@emooreatx

Host inventory 2026-09-24 (information_schema.columns diff, US vs EU cirisnode, same image 5a617c4):

  • evaluations — EU-only columns: batch_config jsonb, checkpoint_at timestamptz, completed_scenario_count integer NOT NULL, model_version varchar, trace_binding jsonb.
  • frontier_models — EU-only: active bool NOT NULL, added_at, eval_config jsonb, id uuid NOT NULL, provider_label, proxy_route; created_at nullable on EU, NOT NULL on US.
  • agent_events, audit_logs, jobs, wbd_tasks, agent_tokens, config — EU has archived integer (US boolean), timestamp (US timestamptz), text where US has jsonb (event_json, results_json, config_json). audit_logs.actor nullable varchar on EU vs NOT NULL text on US.
  • schema_migrations: EU has an extra bare 006 row (applied 2026-02-09 23:57) alongside 006_add_evaluations. EU's migrations were applied by hand over 02-08..02-14; US in one pass on 02-15.

The app tolerates both shapes today (none of the EU-only columns are read in 5a617c4), so nothing is broken yet — but pg_dump-based data movement between them fails, and the next migration that assumes the US shape will behave differently per region.

Asks

  1. cirisnode/db/migrator.py should verify schema shape, not just schema_migrations rows: after applying, compare information_schema.columns for the known tables against an expected manifest (or a checksum committed with each migration) and log/alert on drift. A bare 006 row should be rejected as an unknown version.
  2. Make 001_ensure_core_tables.sql reconcile legacy types (archived integer → boolean, timestamp → timestamptz, text → jsonb with USING ::jsonb) so a hand-initialised DB converges instead of diverging forever.
  3. Consider dropping the EU-only columns explicitly in a migration so the two shapes are identical, or adopt them in code if they were meant to land (checkpoint_at/completed_scenario_count look like CIRISBench's 002_add_checkpoint_columns alembic migration — the two apps migrate the same tables with two migration systems).

Context: CIRISAI/CIRISCore#2 consolidates onto the US database, which retires the EU shape; this issue is about not producing a new divergence.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions