2020-08-27 14:10:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CreateCiPlatformMetrics < ActiveRecord::Migration[6.0]
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
2020-09-01 17:10:21 -04:00
|
|
|
CI_VARIABLES_KEY_INDEX_NAME = "index_ci_variables_on_key"
|
2020-08-27 14:10:29 -04:00
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
|
|
|
unless table_exists?(:ci_platform_metrics)
|
|
|
|
create_table :ci_platform_metrics do |t|
|
|
|
|
t.datetime_with_timezone :recorded_at, null: false
|
|
|
|
t.text :platform_target, null: false
|
|
|
|
t.integer :count, null: false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
add_text_limit :ci_platform_metrics, :platform_target, 255
|
2020-09-01 17:10:21 -04:00
|
|
|
add_concurrent_index :ci_variables, :key, name: CI_VARIABLES_KEY_INDEX_NAME
|
2020-08-27 14:10:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2020-09-01 17:10:21 -04:00
|
|
|
if table_exists?(:ci_platform_metrics)
|
|
|
|
drop_table :ci_platform_metrics
|
|
|
|
end
|
|
|
|
|
|
|
|
remove_concurrent_index :ci_variables, :key, name: CI_VARIABLES_KEY_INDEX_NAME
|
2020-08-27 14:10:29 -04:00
|
|
|
end
|
|
|
|
end
|