diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20200121192942_create_geo_events.rb | 14 | ||||
-rw-r--r-- | db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb | 9 | ||||
-rw-r--r-- | db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb | 20 | ||||
-rw-r--r-- | db/migrate/20200121194154_add_geo_events_foreign_key.rb | 20 | ||||
-rw-r--r-- | db/schema.rb | 10 |
5 files changed, 73 insertions, 0 deletions
diff --git a/db/migrate/20200121192942_create_geo_events.rb b/db/migrate/20200121192942_create_geo_events.rb new file mode 100644 index 00000000000..6dbe131051f --- /dev/null +++ b/db/migrate/20200121192942_create_geo_events.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateGeoEvents < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + create_table :geo_events do |t| + t.string :replicable_name, limit: 255, null: false + t.string :event_name, limit: 255, null: false + t.jsonb :payload, default: {}, null: false + t.datetime_with_timezone :created_at, null: false + end + end +end diff --git a/db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb b/db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb new file mode 100644 index 00000000000..720995164b2 --- /dev/null +++ b/db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddGeoEventIdToGeoEventLog < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + add_column :geo_event_log, :geo_event_id, :integer + end +end diff --git a/db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb b/db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb new file mode 100644 index 00000000000..9b0ec12c959 --- /dev/null +++ b/db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddGeoEventIdIndexToGeoEventLog < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :geo_event_log, :geo_event_id, + where: "(geo_event_id IS NOT NULL)", + using: :btree, + name: 'index_geo_event_log_on_geo_event_id' + end + + def down + remove_concurrent_index :geo_event_log, :geo_event_id, name: 'index_geo_event_log_on_geo_event_id' + end +end diff --git a/db/migrate/20200121194154_add_geo_events_foreign_key.rb b/db/migrate/20200121194154_add_geo_events_foreign_key.rb new file mode 100644 index 00000000000..b5e16e22989 --- /dev/null +++ b/db/migrate/20200121194154_add_geo_events_foreign_key.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddGeoEventsForeignKey < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :geo_event_log, :geo_events, + column: :geo_event_id, + name: 'fk_geo_event_log_on_geo_event_id', + on_delete: :cascade + end + + def down + remove_foreign_key_without_error :geo_event_log, column: :geo_event_id, name: 'fk_geo_event_log_on_geo_event_id' + end +end diff --git a/db/schema.rb b/db/schema.rb index c69be4844ff..1c96e4eefcf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1665,8 +1665,10 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do t.bigint "reset_checksum_event_id" t.bigint "cache_invalidation_event_id" t.bigint "container_repository_updated_event_id" + t.integer "geo_event_id" t.index ["cache_invalidation_event_id"], name: "index_geo_event_log_on_cache_invalidation_event_id", where: "(cache_invalidation_event_id IS NOT NULL)" t.index ["container_repository_updated_event_id"], name: "index_geo_event_log_on_container_repository_updated_event_id" + t.index ["geo_event_id"], name: "index_geo_event_log_on_geo_event_id", where: "(geo_event_id IS NOT NULL)" t.index ["hashed_storage_attachments_event_id"], name: "index_geo_event_log_on_hashed_storage_attachments_event_id", where: "(hashed_storage_attachments_event_id IS NOT NULL)" t.index ["hashed_storage_migrated_event_id"], name: "index_geo_event_log_on_hashed_storage_migrated_event_id", where: "(hashed_storage_migrated_event_id IS NOT NULL)" t.index ["job_artifact_deleted_event_id"], name: "index_geo_event_log_on_job_artifact_deleted_event_id", where: "(job_artifact_deleted_event_id IS NOT NULL)" @@ -1680,6 +1682,13 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do t.index ["upload_deleted_event_id"], name: "index_geo_event_log_on_upload_deleted_event_id", where: "(upload_deleted_event_id IS NOT NULL)" end + create_table "geo_events", force: :cascade do |t| + t.string "replicable_name", limit: 255, null: false + t.string "event_name", limit: 255, null: false + t.jsonb "payload", default: {}, null: false + t.datetime_with_timezone "created_at", null: false + end + create_table "geo_hashed_storage_attachments_events", force: :cascade do |t| t.integer "project_id", null: false t.text "old_attachments_path", null: false @@ -4650,6 +4659,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do add_foreign_key "geo_container_repository_updated_events", "container_repositories", name: "fk_212c89c706", on_delete: :cascade add_foreign_key "geo_event_log", "geo_cache_invalidation_events", column: "cache_invalidation_event_id", name: "fk_42c3b54bed", on_delete: :cascade add_foreign_key "geo_event_log", "geo_container_repository_updated_events", column: "container_repository_updated_event_id", name: "fk_6ada82d42a", on_delete: :cascade + add_foreign_key "geo_event_log", "geo_events", name: "fk_geo_event_log_on_geo_event_id", on_delete: :cascade add_foreign_key "geo_event_log", "geo_hashed_storage_migrated_events", column: "hashed_storage_migrated_event_id", name: "fk_27548c6db3", on_delete: :cascade add_foreign_key "geo_event_log", "geo_job_artifact_deleted_events", column: "job_artifact_deleted_event_id", name: "fk_176d3fbb5d", on_delete: :cascade add_foreign_key "geo_event_log", "geo_lfs_object_deleted_events", column: "lfs_object_deleted_event_id", name: "fk_d5af95fcd9", on_delete: :cascade |