Commit f744779e authored by Aakriti Gupta's avatar Aakriti Gupta Committed by Douglas Barbosa Alexandre

Add multiple improvements to Geo development docs

parent a78c66cd
......@@ -56,9 +56,7 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org
```ruby
# frozen_string_literal: true
class CreateCoolWidgetRegistry < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
class CreateCoolWidgetRegistry < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
......@@ -126,9 +124,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
```ruby
# frozen_string_literal: true
class CreateCoolWidgetStates < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
class CreateCoolWidgetStates < Gitlab::Database::Migration[1.0]
VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state"
PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification"
FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification"
......@@ -137,7 +133,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
disable_ddl_transaction!
def up
unless table_exists?(:cool_widget_states)
with_lock_retries do
create_table :cool_widget_states, id: false do |t|
t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
......@@ -155,7 +150,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
end
end
end
add_text_limit :cool_widget_states, :verification_failure, 255
end
......@@ -209,6 +203,8 @@ That's all of the required database changes.
has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState'
after_save :save_verification_details
delegate :verification_retry_at, :verification_retry_at=,
:verified_at, :verified_at=,
:verification_checksum, :verification_checksum=,
......@@ -223,6 +219,8 @@ That's all of the required database changes.
scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) }
scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) }
scope :available_verifiables, -> { joins(:cool_widget_state) }
# Override the `all` default if not all records can be replicated. For an
# example of an existing Model that needs to do this, see
# `EE::MergeRequestDiff`.
......
......@@ -58,13 +58,10 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org
```ruby
# frozen_string_literal: true
class CreateCoolWidgetRegistry < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
class CreateCoolWidgetRegistry < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
unless table_exists?(:cool_widget_registry)
ActiveRecord::Base.transaction do
create_table :cool_widget_registry, id: :bigserial, force: :cascade do |t|
t.bigint :cool_widget_id, null: false
......@@ -96,7 +93,6 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org
end
end
end
end
def down
drop_table :cool_widget_registry
......@@ -130,9 +126,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
```ruby
# frozen_string_literal: true
class CreateCoolWidgetStates < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
class CreateCoolWidgetStates < Gitlab::Database::Migration[1.0]
VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state"
PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification"
FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification"
......@@ -141,7 +135,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
disable_ddl_transaction!
def up
unless table_exists?(:cool_widget_states)
with_lock_retries do
create_table :cool_widget_states, id: false do |t|
t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
......@@ -159,7 +152,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
end
end
end
add_text_limit :cool_widget_states, :verification_failure, 255
end
......@@ -213,6 +205,8 @@ That's all of the required database changes.
has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState'
after_save :save_verification_details
delegate :verification_retry_at, :verification_retry_at=,
:verified_at, :verified_at=,
:verification_checksum, :verification_checksum=,
......@@ -227,6 +221,8 @@ That's all of the required database changes.
scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) }
scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) }
scope :available_verifiables, -> { joins(:cool_widget_state) }
# Override the `all` default if not all records can be replicated. For an
# example of an existing Model that needs to do this, see
# `EE::MergeRequestDiff`.
......
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