Commit 34aab0b7 authored by Ian Baum's avatar Ian Baum Committed by Michael Kozono

Migrate lfs_object_registry to new format

* In order to migrate LFS replication to use the Geo self service
  framework, we need to migrate to use Geo::ReplicableRegistry. These
migrations will put the lfs_object_registry table in the appropriate
format for migrating to the new registry.

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52636
parent 03669dea
---
title: Migrate lfs_object_registry to be compatible with Geo::ReplicableRegistry
merge_request: 52636
author:
type: changed
# frozen_string_literal: true
class MigrateLfsObjectRegistry < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
change_column_default :lfs_object_registry, :retry_count, from: nil, to: 0
add_column :lfs_object_registry, :state, :integer, null: false, limit: 2, default: 0
add_column :lfs_object_registry, :last_synced_at, :datetime_with_timezone
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20210225200858_add_text_limit_to_lfs_object_registry_last_sync_failure
add_column :lfs_object_registry, :last_sync_failure, :text
# rubocop:enable Migration/AddLimitToTextColumns
end
def down
change_column_default :lfs_object_registry, :retry_count, from: 0, to: nil
remove_column :lfs_object_registry, :state
remove_column :lfs_object_registry, :last_synced_at
remove_column :lfs_object_registry, :last_sync_failure
end
end
# frozen_string_literal: true
class AddLfsObjectStateIndex < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_state_in_lfs_objects'
disable_ddl_transaction!
def up
add_concurrent_index :lfs_object_registry, :state, name: INDEX_NAME
end
def down
remove_concurrent_index :lfs_object_registry, :state, name: INDEX_NAME
end
end
# frozen_string_literal: true
class AddTextLimitToLfsObjectRegistryLastSyncFailure < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_text_limit :lfs_object_registry, :last_sync_failure, 255
end
def down
remove_text_limit :lfs_object_registry, :last_sync_failure
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: 2021_02_17_020156) do ActiveRecord::Schema.define(version: 2021_02_25_200858) 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 "plpgsql" enable_extension "plpgsql"
...@@ -82,12 +82,16 @@ ActiveRecord::Schema.define(version: 2021_02_17_020156) do ...@@ -82,12 +82,16 @@ ActiveRecord::Schema.define(version: 2021_02_17_020156) do
t.datetime_with_timezone "retry_at" t.datetime_with_timezone "retry_at"
t.bigint "bytes" t.bigint "bytes"
t.integer "lfs_object_id" t.integer "lfs_object_id"
t.integer "retry_count" t.integer "retry_count", default: 0
t.boolean "missing_on_primary", default: false, null: false t.boolean "missing_on_primary", default: false, null: false
t.boolean "success", default: false, null: false t.boolean "success", default: false, null: false
t.binary "sha256" t.binary "sha256"
t.integer "state", limit: 2, default: 0, null: false
t.datetime_with_timezone "last_synced_at"
t.text "last_sync_failure"
t.index ["lfs_object_id"], name: "index_lfs_object_registry_on_lfs_object_id", unique: true t.index ["lfs_object_id"], name: "index_lfs_object_registry_on_lfs_object_id", unique: true
t.index ["retry_at"], name: "index_lfs_object_registry_on_retry_at" t.index ["retry_at"], name: "index_lfs_object_registry_on_retry_at"
t.index ["state"], name: "index_state_in_lfs_objects"
t.index ["success"], name: "index_lfs_object_registry_on_success" t.index ["success"], name: "index_lfs_object_registry_on_success"
end end
......
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