For example: add_concurrent_index ( :users, :updated_at ) end end Start by creating the post-deployment migration:Ĭlass RemoveUsersUpdatedAtColumn < Gitlab :: Database :: Migration disable_ddl_transaction! def up remove_column :users, :updated_at end def down unless column_exists? ( :users, :updated_at ) add_column :users, :updated_at, :datetime end # Make sure to add back any indexes or constraints, # that were dropped in the `up` method. Step 2: Dropping the column (release M+1)Ĭontinuing our example, dropping the column goes into a post-deployment migration in release 12.6: In this example, the change to ignore the column went into release 12.5. To ignore the column and subsequently remove the column ignore (which would result in a downtime). ForĮxample, this avoids a situation where we deploy a bulk of changes that include both changes This information allows us to reason better about column ignores and makes sure weĭon’t remove column ignores too early for both regular releases and deployments to. Ignore, typically after the M+1 release date, during the M+2 development cycle. remove_after: set to a date after which we consider it safe to remove the column.remove_with: set to a GitLab release typically two releases (M+2) after adding the.We require indication of when it is safe to remove the column ignore with: Model only exists in EE, then it has to be added there. If the model exists in CE and EE, the column has to be ignored in the CE model. Ignore_columns %i, remove_with: '12.7', remove_after: '' Updated_at in the User model you’d use the following: This can be done by defining the columns to ignore. Necessary because Rails caches the columns and re-uses this cache in various The first step is to ignore the column in the application code. The reason we spread this out across three releases is that dropping a column isĪ destructive operation that can’t be rolled back easily.įollowing this procedure helps us to make sure there are no deployments to Īnd upgrade processes for self-managed installations that lump together any of these steps. To work around this safely, you need three steps in three releases: Removing columns is tricky because running GitLab processes may still be using May appear to need downtime, their impact, and how to perform them without This guide describes various operations that Since weĬannot have downtime in migrations we need to use a set of steps to get the When working with a database certain operations may require downtime. Data migrations Avoiding downtime in migrations.Remove the trigger and old integer columns (release N + 2).High-level status of batched background migrations.Initialize the conversion and start migrating existing data (release N).Migrating integer primary keys to bigint.Step 2: Create A Post Deployment Migration.Step 2: Add A Post-Deployment Migration.Step 3: Removing the ignore rule (release M+2).The removed column has an index or constraint that belongs to it The removed column has no indexes or constraints that belong to it Step 2: Dropping the column (release M+1).Step 1: Ignoring the column (release M).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |