Apply a rehearsed merge to its target
Refuses, in this order: a merge that isn't rehearsed (merge_not_rehearsed, or merge_stale for a stale one); a version that isn't the merge's (merge_version_conflict: a save of acknowledgements or the after-merge choice keeps a merge rehearsed, so send the version you last saw to apply what you saw); conflicts without a resolution (merge_conflicts_open); data-loss, security (BYPASSRLS, owner-level) or breaking (a role rename) steps without an acknowledgement (merge_drops_unacknowledged); a protected target without confirm: true (merge_confirm_required); another merge applying to the target, or failed half applied on it (merge_busy). The worker then runs the plan (applying, then online for the concurrent index and validation steps, then finishing). The request doesn't read the target: before the plan's transaction the worker compares the target with the schema the plan was computed from, and if it changed, ends the merge stale without applying the transaction.
Authorization
bearer In: header
Path Parameters
Database id
uuidMerge id
uuidRequest Body
application/json
Optional; an empty body is {}
TypeScript Definitions
Use the request body type in TypeScript.
Required to merge into a protected branch.
The version you last saw (send it: a save since, such as a new after-merge choice,
keeps the merge rehearsed); another one is a 409 merge_version_conflict.
int64Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/databases/497f6eca-6276-4993-bfeb-53cbbbba6f08/merges/497f6eca-6276-4993-bfeb-53cbbbba6f08/apply" \ -H "Content-Type: application/json" \ -d '{}'{ "created_at": "2019-08-24T14:15:22Z", "created_by": "string", "database": "string", "direction": "into_parent", "error": "string", "failed_phase": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "rebaselined": true, "source_branch_id": "345f76de-8f9d-4a8f-b08e-a28a3db17483", "status": "computing", "target_branch_id": "2a8880d3-8c08-4fef-81e0-ec9d6c6def29", "updated_at": "2019-08-24T14:15:22Z", "version": 0}Give up a merge that failed half applied POST
For a merge `failed` in the `online` phase: its transaction is on the target, its online steps didn't all run, and it holds both branches until it is retried to the end or abandoned. Abandoning makes it `cancelled` and frees the branches. Nothing on the target is undone: `result.leftovers` lists what the merge left there that the online phase didn't finish, each `{kind, schema, table, name}`: `not_valid_constraint` (a constraint added `NOT VALID`, never validated; it still checks new rows); `not_null_check` (a temporary `chelabase_merge_nn_*` check that wasn't dropped); `invalid_index` (the index the online phase was building, or dropping concurrently, when it stopped: Postgres may have left it INVALID, unused by queries but still updated by writes; it may also not be there); `unattached_index` (a valid index the merge built that its next step didn't put into place: a temporary `chelabase_merge_ix_*` index not renamed over the one it replaces, or a unique constraint's index not attached to its constraint; nothing uses it, and it costs on every write). Validate, attach or drop them by hand (`DROP INDEX CONCURRENTLY IF EXISTS` for an index).
Cancel a merge POST
Stops a merge that isn't changing the target: `computing`, `draft`, `rehearsing` (the worker deletes the rehearsal branch; until it is gone the target's reset, restore and delete answer `branch_merge_busy` with `error.rehearsal_branch_id`) or `rehearsed`. An applying merge can't be cancelled, and a merge failed in `online` is abandoned instead.