Help us learn about your current experience with the documentation. Take the survey.

Batched background migrations API

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed

Use this API to monitor and manage batched background migrations.

Prerequisites:

  • You must have administrator access to the instance.

List the last 20 batched background migrations

List all batched background migrations.

GET /api/v4/admin/batched_background_migrations

Supported attributes:

AttributeTypeRequiredDescription
databasestringNoName of the database. Defaults to main.
job_class_namestringNoFilter migrations by job class name.

If successful, returns 200 OK and the following response attributes:

AttributeTypeDescription
column_namestringName of the column the migration iterates over.
created_atdatetimeTimestamp of when the migration was created.
estimated_time_remainingstringEstimated time until the migration completes. Sometimes null
idintegerID of the batched background migration.
job_class_namestringName of the migration job class.
progressfloatCompletion percentage of the migration.
statusstringStatus of the migration. Can be paused, active, finished, failed, finalizing, or finalized.
table_namestringName of the table the migration iterates over.

Example request:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/admin/batched_background_migrations"

Example response:

[
  {
    "id": 1234,
    "job_class_name": "CopyColumnUsingBackgroundMigrationJob",
    "table_name": "events",
    "column_name": "id",
    "status": "active",
    "progress": 50.0,
    "created_at": "2022-11-28T16:26:39+02:00",
    "estimated_time_remaining": "1 day"
  }
]

Retrieve a batched background migration

Retrieve a batched background migration.

GET /api/v4/admin/batched_background_migrations/:id

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesID of the batched background migration.
databasestringNoName of the database. Defaults to main.

If successful, returns 200 OK and the following response attributes:

AttributeTypeDescription
column_namestringName of the column the migration iterates over.
created_atdatetimeTimestamp of when the migration was created.
estimated_time_remainingstringEstimated time until the migration completes.
idintegerID of the batched background migration.
job_class_namestringName of the migration job class.
progressfloatCompletion percentage of the migration.
statusstringStatus of the migration. Can be paused, active, finished, failed, finalizing, or finalized.
table_namestringName of the table the migration iterates over.

Example request:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/admin/batched_background_migrations/1234"

Example response:

{
  "id": 1234,
  "job_class_name": "CopyColumnUsingBackgroundMigrationJob",
  "table_name": "events",
  "column_name": "id",
  "status": "active",
  "progress": 50.0,
  "created_at": "2022-11-28T16:26:39+02:00",
  "estimated_time_remaining": "1 day"
}

Pause a batched background migration

Pause a batched background migration. You can pause only migrations with an active status.

PUT /api/v4/admin/batched_background_migrations/:id/pause

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesID of the batched background migration.
databasestringNoName of the database. Defaults to main.

If successful, returns 200 OK and the following response attributes:

AttributeTypeDescription
column_namestringName of the column the migration iterates over.
created_atdatetimeTimestamp of when the migration was created.
estimated_time_remainingstringEstimated time until the migration completes.
idintegerID of the batched background migration.
job_class_namestringName of the migration job class.
progressfloatCompletion percentage of the migration.
statusstringStatus of the migration. Can be paused, active, finished, failed, finalizing, or finalized.
table_namestringName of the table the migration iterates over.

If the migration does not have an active status, returns 422 Unprocessable Entity.

Example request:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/admin/batched_background_migrations/1234/pause"

Example response:

{
  "id": 1234,
  "job_class_name": "CopyColumnUsingBackgroundMigrationJob",
  "table_name": "events",
  "column_name": "id",
  "status": "paused",
  "progress": 50.0,
  "created_at": "2022-11-28T16:26:39+02:00",
  "estimated_time_remaining": "1 day"
}

Resume a batched background migration

Resume a batched background migration. You can resume only migrations with a paused status.

PUT /api/v4/admin/batched_background_migrations/:id/resume

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesID of the batched background migration.
databasestringNoName of the database. Defaults to main.

If successful, returns 200 OK and the following response attributes:

AttributeTypeDescription
column_namestringName of the column the migration iterates over.
created_atdatetimeTimestamp of when the migration was created.
estimated_time_remainingstringEstimated time until the migration completes.
idintegerID of the batched background migration.
job_class_namestringName of the migration job class.
progressfloatCompletion percentage of the migration.
statusstringStatus of the migration. Can be paused, active, finished, failed, finalizing, or finalized.
table_namestringName of the table the migration iterates over.

If the migration does not have a paused status, returns 422 Unprocessable Entity.

Example request:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/admin/batched_background_migrations/1234/resume"

Example response:

{
  "id": 1234,
  "job_class_name": "CopyColumnUsingBackgroundMigrationJob",
  "table_name": "events",
  "column_name": "id",
  "status": "active",
  "progress": 50.0,
  "created_at": "2022-11-28T16:26:39+02:00",
  "estimated_time_remaining": "1 day"
}