debian-mirror-gitlab/doc/development/deleting_migrations.md

40 lines
1.7 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
stage: none
group: unassigned
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2019-12-21 20:55:43 +05:30
# Delete existing migrations
When removing existing migrations from the GitLab project, you have to take into account
2020-04-08 14:13:33 +05:30
the possibility of the migration already been included in past releases or in the current release, and thus already executed on GitLab.com and/or in self-managed instances.
2019-12-21 20:55:43 +05:30
Because of it, it's not possible to delete existing migrations, as that could lead to:
2020-06-23 00:09:42 +05:30
- Schema inconsistency, as changes introduced into the database were not rolled back properly.
2019-12-21 20:55:43 +05:30
- Leaving a record on the `schema_versions` table, that points out to migration that no longer exists on the codebase.
Instead of deleting we can opt for disabling the migration.
## Pre-requisites to disable a migration
Migrations can be disabled if:
- They caused a timeout or general issue on GitLab.com.
- They are obsoleted, e.g. changes are not necessary due to a feature change.
- Migration is a data migration only, i.e. the migration does not change the database schema.
## How to disable a data migration?
In order to disable a migration, the following steps apply to all types of migrations:
2020-06-23 00:09:42 +05:30
1. Turn the migration into a no-op by removing the code inside `#up`, `#down`
2020-10-24 23:57:45 +05:30
or `#perform` methods, and adding `# no-op` comment instead.
2019-12-21 20:55:43 +05:30
1. Add a comment explaining why the code is gone.
Disabling migrations requires explicit approval of Database Maintainer.
## Examples
2020-03-13 15:44:24 +05:30
- [Disable scheduling of productivity analytics](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/17253)