Commit 3dc91d60 authored by Mario de la Ossa's avatar Mario de la Ossa

Set all LockVersion columns to default to 0

We have some custom middleware that makes lock_version behave properly
when it's set to `nil`, but we want to get rid of it, so before that
let's make sure all new data coming in gets defaulted to a good value
instead of `nil`.
parent 07bd816e
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForMergeRequests < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
with_lock_retries do
change_column_default :merge_requests, :lock_version, from: nil, to: 0
end
end
end
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForIssues < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
with_lock_retries do
change_column_default :issues, :lock_version, from: nil, to: 0
end
end
end
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForEpics < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
with_lock_retries do
change_column_default :epics, :lock_version, from: nil, to: 0
end
end
end
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForCiBuilds < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
with_lock_retries do
change_column_default :ci_builds, :lock_version, from: nil, to: 0
end
end
end
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForCiStages < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
with_lock_retries do
change_column_default :ci_stages, :lock_version, from: nil, to: 0
end
end
end
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForCiPipelines < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
with_lock_retries do
change_column_default :ci_pipelines, :lock_version, from: nil, to: 0
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_01_30_161817) do ActiveRecord::Schema.define(version: 2020_02_03_025821) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm" enable_extension "pg_trgm"
...@@ -659,7 +659,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do ...@@ -659,7 +659,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do
t.text "yaml_variables" t.text "yaml_variables"
t.datetime "queued_at" t.datetime "queued_at"
t.string "token" t.string "token"
t.integer "lock_version" t.integer "lock_version", default: 0
t.string "coverage_regex" t.string "coverage_regex"
t.integer "auto_canceled_by_id" t.integer "auto_canceled_by_id"
t.boolean "retried" t.boolean "retried"
...@@ -835,7 +835,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do ...@@ -835,7 +835,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do
t.datetime "finished_at" t.datetime "finished_at"
t.integer "duration" t.integer "duration"
t.integer "user_id" t.integer "user_id"
t.integer "lock_version" t.integer "lock_version", default: 0
t.integer "auto_canceled_by_id" t.integer "auto_canceled_by_id"
t.integer "pipeline_schedule_id" t.integer "pipeline_schedule_id"
t.integer "source" t.integer "source"
...@@ -949,7 +949,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do ...@@ -949,7 +949,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do
t.datetime "updated_at" t.datetime "updated_at"
t.string "name" t.string "name"
t.integer "status" t.integer "status"
t.integer "lock_version" t.integer "lock_version", default: 0
t.integer "position" t.integer "position"
t.index ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name", unique: true t.index ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name", unique: true
t.index ["pipeline_id", "position"], name: "index_ci_stages_on_pipeline_id_and_position" t.index ["pipeline_id", "position"], name: "index_ci_stages_on_pipeline_id_and_position"
...@@ -1523,7 +1523,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do ...@@ -1523,7 +1523,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do
t.integer "cached_markdown_version" t.integer "cached_markdown_version"
t.integer "updated_by_id" t.integer "updated_by_id"
t.integer "last_edited_by_id" t.integer "last_edited_by_id"
t.integer "lock_version" t.integer "lock_version", default: 0
t.date "start_date" t.date "start_date"
t.date "end_date" t.date "end_date"
t.datetime "last_edited_at" t.datetime "last_edited_at"
...@@ -2140,7 +2140,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do ...@@ -2140,7 +2140,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do
t.boolean "confidential", default: false, null: false t.boolean "confidential", default: false, null: false
t.date "due_date" t.date "due_date"
t.integer "moved_to_id" t.integer "moved_to_id"
t.integer "lock_version" t.integer "lock_version", default: 0
t.text "title_html" t.text "title_html"
t.text "description_html" t.text "description_html"
t.integer "time_estimate" t.integer "time_estimate"
...@@ -2562,7 +2562,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do ...@@ -2562,7 +2562,7 @@ ActiveRecord::Schema.define(version: 2020_01_30_161817) do
t.integer "approvals_before_merge" t.integer "approvals_before_merge"
t.string "rebase_commit_sha" t.string "rebase_commit_sha"
t.string "in_progress_merge_commit_sha" t.string "in_progress_merge_commit_sha"
t.integer "lock_version" t.integer "lock_version", default: 0
t.text "title_html" t.text "title_html"
t.text "description_html" t.text "description_html"
t.integer "time_estimate" t.integer "time_estimate"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment