{"record":{"id":"0df7b7191efe9a4f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-migrate-execution-transaction-table-e","errorCode":null,"errorMessage":"Failed to migrate execution_transaction table: {e}","messagePattern":"Failed to migrate execution_transaction table: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":3587,"sourceCode":"                from_status TEXT,\n                to_status TEXT NOT NULL,\n                block_number BIGINT,\n                block_hash TEXT,\n                observed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\n                CHECK (block_number IS NULL OR block_number >= 0),\n                CHECK (to_status IN (\n                    'prepared', 'signed', 'broadcast', 'included', 'finalized',\n                    'reverted', 'replaced', 'dropped', 'reorged', 'recoverable'\n                )),\n                UNIQUE (intent_id, transition_key)\n            )\n            \",\n        ] {\n            sqlx::query(statement)\n                .execute(&mut *transaction)\n                .await\n                .map_err(|e| {\n                    anyhow::anyhow!(\"Failed to migrate execution_transaction table: {e}\")\n                })?;\n        }\n\n        let installed_version = sqlx::query_scalar::<_, i16>(\n            \"SELECT version FROM execution_schema_version WHERE component = 'evm_execution'\",\n        )\n        .fetch_optional(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to read execution schema version: {e}\"))?;\n        if let Some(installed_version) = installed_version\n            && installed_version > EXECUTION_SCHEMA_VERSION\n        {\n            anyhow::bail!(\n                \"Execution schema version {} is newer than supported version {EXECUTION_SCHEMA_VERSION}\",\n                installed_version\n            );\n        }\n","sourceCodeStart":3569,"sourceCodeEnd":3605,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L3569-L3605","documentation":"This error wraps failure executing one of the DDL migration statements (e.g. ALTER TABLE execution_transaction ADD COLUMN IF NOT EXISTS ...) inside the migration transaction. The library throws it to attribute the failure to the table migration step specifically.","triggerScenarios":"Executing the migration statements when a column already exists with an incompatible type, insufficient privileges for ALTER TABLE, the lock was lost (statement trigger on a different table), or syntax/type errors in a statement for the target Postgres version.","commonSituations":"Running with a DB user lacking DDL privileges; mixed schema versions where a column exists as a different type; older Postgres versions not supporting IF NOT EXISTS variants.","solutions":["Check the inner `{e}` for the failing statement and Postgres error code","Verify the migration user has ALTER privileges on the table","Inspect current column types via information_schema and reconcile with expected types","Run migrations against a staging copy of the database first"],"exampleFix":"// before\n.map_err(|e| anyhow::anyhow!(\"Failed to migrate execution_transaction table: {e}\"))?;\n// after\n.map_err(|e| {\n    tracing::error!(error = %e, statement, \"execution_transaction DDL failed\");\n    anyhow::anyhow!(\"Failed to migrate execution_transaction table: {e}\")\n})?;","handlingStrategy":"try-catch","validationCode":"let can_alter = sqlx::query_scalar::<_, bool>(\n    \"SELECT has_table_privilege(current_user, 'execution_transaction', 'ALTER')\"\n).fetch_one(&pool).await?;\nif !can_alter { anyhow::bail!(\"migration user lacks ALTER privilege on execution_transaction\"); }","typeGuard":null,"tryCatchPattern":"match ensure_execution_transaction_schema().await {\n    Ok(()) => (),\n    Err(e) if e.to_string().contains(\"Failed to migrate\") => {\n        inspect_column_types(&pool).await?; // diagnose via information_schema\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Grant the migration user DDL privileges","Test migrations against a staging copy of production schema","Keep all environments on the same schema version before deploying"],"tags":["database","migration","ddl","postgres"],"backgroundTag":"database-query-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}