Skip to content

Set all LockVersion columns to default to 0

Mario de la Ossa requested to merge default_lock_version_to_zero into master

What does this MR do?

In !18418 (merged) we're removing a middleware that makes lock_version behave properly when we it has nil values, but before that we should already be making sure we minimize the amount of nils in our database.

This sets a default value of 0 to all the tables that have a lock_version column.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Database

Migration output:

== 20200203025400 DefaultLockVersionToZeroForMergeRequests: migrating =========
-- change_column_default(:merge_requests, :lock_version, {:from=>nil, :to=>0})
   -> 0.0141s
== 20200203025400 DefaultLockVersionToZeroForMergeRequests: migrated (0.0142s)

== 20200203025602 DefaultLockVersionToZeroForIssues: migrating ================
-- change_column_default(:issues, :lock_version, {:from=>nil, :to=>0})
   -> 0.0054s
== 20200203025602 DefaultLockVersionToZeroForIssues: migrated (0.0056s) =======

== 20200203025619 DefaultLockVersionToZeroForEpics: migrating =================
-- change_column_default(:epics, :lock_version, {:from=>nil, :to=>0})
   -> 0.0050s
== 20200203025619 DefaultLockVersionToZeroForEpics: migrated (0.0051s) ========

== 20200203025744 DefaultLockVersionToZeroForCiBuilds: migrating ==============
-- change_column_default(:ci_builds, :lock_version, {:from=>nil, :to=>0})
   -> 0.0053s
== 20200203025744 DefaultLockVersionToZeroForCiBuilds: migrated (0.0054s) =====

== 20200203025801 DefaultLockVersionToZeroForCiStages: migrating ==============
-- change_column_default(:ci_stages, :lock_version, {:from=>nil, :to=>0})
   -> 0.0046s
== 20200203025801 DefaultLockVersionToZeroForCiStages: migrated (0.0047s) =====

== 20200203025821 DefaultLockVersionToZeroForCiPipelines: migrating ===========
-- change_column_default(:ci_pipelines, :lock_version, {:from=>nil, :to=>0})
   -> 0.0048s
== 20200203025821 DefaultLockVersionToZeroForCiPipelines: migrated (0.0049s) ==

Merge request reports