Skip to content

Add API to mark migrations as successful

Marius Bobin requested to merge mb-mark-migrations-api into master

What does this MR do and why?

For CI partitioning we have added lots of migrations and some of them failed because of external factors(too much traffic, conflicting locks due to vacuum) and we had to create change management issues to mark the migrations as successfully executed and unblock the release process. This MR adds an API endpoint for this and it will be used by a chatops command to make the process easier and faster: gitlab-com/chatops!381 (merged)

The last occurrence: gitlab-com/gl-infra/production#14888 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. in development.rb change config.active_record.migration_error = :page_load to config.active_record.migration_error = :false so that the server boots successfully.
  2. generate a migration file bin/rails g post_deployment_migration test_api_migration_skip
  3. Get the version number for the generated migration and use it in the following command
  4. curl -H 'PRIVATE-TOKEN: glpat-token' -X POST 'http://localhost:3000/api/v4/admin/migrations/:version/mark?database=main' -v
  5. check the main database gdk psql, select * from schema_migrations where version = ':version';
  6. Repeat with the ci database.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marius Bobin

Merge request reports