Skip to content

Revert a journaled table operation by its `migration_id`. Refused (nothing written) when any

POST
/datanotes/operations/undo_migration/
curl --request POST \
--url https://example.com/datanotes/operations/undo_migration/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Datanotes-Actor: {"harness":"my-script","model":"","session":"s-1"}' \
--data '{ "migration_id": "example" }'

Revert a journaled table operation by its migration_id. Refused (nothing written) when any touched note changed since; the conflicts are listed. Also refused when the revert would leave rows breaking a CHECK that follows links or a ref_where / ref_by (rows it writes, or rows that link to them), listed like the refusals of other writes with the way out (fix the row, or drop the rule). The rules are those of the schema the revert puts back: undoing a rename_value / rename_column puts the old names back with the rows, and a rule the revert puts back must hold on every row. A batch is checked as a whole first (nothing written when refused), then reverted operation by operation, from the last; when one finds a note changed since, those after it stay reverted and a retry skips them. An undo is journaled like any operation: undoing it (the migration_id of its answer; undoes names the operation undone) is a redo, whatever the operation (a batch included). The revert is a new version (UNDO) in the transaction log; undoing a table’s rename or move takes its whole log back to the old name, the versions made under the new one included.

The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).

X-Datanotes-Actor
string

JSON: on whose behalf the write is made, recorded in the journal (harness, model, session).

Example

{"harness":"my-script","model":"","session":"s-1"}
Media typeapplication/json
object
migration_id
required
string

Example generated

{
"migration_id": "example"
}

Done.

Media typeapplication/json

Result of undo_migration (HTTP 409 when refused, 500 when a write failed).

object
ok
required

True when the operation was undone.

boolean
op
required

The operation: undo_migration, in the answer and in a refusal.

string
Allowed value: undo_migration
undoes
required

The operation undone.

string
migration_id

Journal id of the undo itself (undo it to redo the operation).

string
conflicts
required

Why it could not be undone (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
failed
required
Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string

Example

{
"op": "undo_migration"
}

Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Missing or wrong bearer token.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

A named token beyond its permissions (the engine’s administration, tables outside its write patterns, schema changes without ddl).

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Unknown table, view, migration, note or folder.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Undo refused (later changes depend on it, or it was undone already): nothing written (a batch is checked as a whole first; when one of its operations then finds a note changed since, the operations after it stay reverted: touched, and a retry skips them). Same body as 200, with ok: false.

Media typeapplication/json
Any of:

Result of undo_migration (HTTP 409 when refused, 500 when a write failed).

object
ok
required

True when the operation was undone.

boolean
op
required

The operation: undo_migration, in the answer and in a refusal.

string
Allowed value: undo_migration
undoes
required

The operation undone.

string
migration_id

Journal id of the undo itself (undo it to redo the operation).

string
conflicts
required

Why it could not be undone (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
failed
required
Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string

Example

{
"op": "undo_migration"
}

Unexpected error ({error}), or a write that failed partway and could not be rolled back: rolled_back: false, failed lists the files left (undo_migration on migration_id retries the rollback).

Media typeapplication/json
Any of:

Result of undo_migration (HTTP 409 when refused, 500 when a write failed).

object
ok
required

True when the operation was undone.

boolean
op
required

The operation: undo_migration, in the answer and in a refusal.

string
Allowed value: undo_migration
undoes
required

The operation undone.

string
migration_id

Journal id of the undo itself (undo it to redo the operation).

string
conflicts
required

Why it could not be undone (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
failed
required
Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string

Example

{
"op": "undo_migration"
}