Commit 248b4719 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '335386-create-new-vsa-tables' into 'master'

Add new VSA partitioned tables

See merge request gitlab-org/gitlab!68950
parents 9e0fc449 0a29fd92
# frozen_string_literal: true
module Analytics
module CycleAnalytics
class IssueStageEvent < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
validates(*%i[stage_event_hash_id issue_id group_id project_id start_event_timestamp], presence: true)
end
end
end
# frozen_string_literal: true
module Analytics
module CycleAnalytics
class MergeRequestStageEvent < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
validates(*%i[stage_event_hash_id merge_request_id group_id project_id start_event_timestamp], presence: true)
end
end
end
# frozen_string_literal: true
class CreateAnalyticsCycleAnalyticsMergeRequestStageEvents < ActiveRecord::Migration[6.1]
include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
include Gitlab::Database::MigrationHelpers
def up
execute <<~SQL
CREATE TABLE analytics_cycle_analytics_merge_request_stage_events (
stage_event_hash_id bigint NOT NULL,
merge_request_id bigint NOT NULL,
group_id bigint NOT NULL,
project_id bigint NOT NULL,
milestone_id bigint,
author_id bigint,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone,
PRIMARY KEY (stage_event_hash_id, merge_request_id)
) PARTITION BY HASH (stage_event_hash_id)
SQL
create_hash_partitions :analytics_cycle_analytics_merge_request_stage_events, 32
end
def down
drop_table :analytics_cycle_analytics_merge_request_stage_events
end
end
# frozen_string_literal: true
class CreateAnalyticsCycleAnalyticsIssueStageEvents < ActiveRecord::Migration[6.1]
include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers
include Gitlab::Database::MigrationHelpers
def up
execute <<~SQL
CREATE TABLE analytics_cycle_analytics_issue_stage_events (
stage_event_hash_id integer NOT NULL,
issue_id integer NOT NULL,
group_id integer NOT NULL,
project_id integer NOT NULL,
milestone_id integer,
author_id integer,
start_event_timestamp timestamp with time zone NOT NULL,
end_event_timestamp timestamp with time zone,
PRIMARY KEY (stage_event_hash_id, issue_id)
) PARTITION BY HASH (stage_event_hash_id)
SQL
create_hash_partitions :analytics_cycle_analytics_issue_stage_events, 32
end
def down
drop_table :analytics_cycle_analytics_issue_stage_events
end
end
c15d736eb441503d321e1bf377edd204aa1b5822ed697cce2934ff87eca441a9
\ No newline at end of file
e9e8444056a114d471f60156ec1e5a96082c7922604f1926c0256eb17986c484
\ No newline at end of file
This diff is collapsed.
...@@ -18,6 +18,8 @@ RSpec.describe 'Database schema' do ...@@ -18,6 +18,8 @@ RSpec.describe 'Database schema' do
approvals: %w[user_id], approvals: %w[user_id],
approver_groups: %w[target_id], approver_groups: %w[target_id],
approvers: %w[target_id user_id], approvers: %w[target_id user_id],
analytics_cycle_analytics_merge_request_stage_events: %w[author_id group_id merge_request_id milestone_id project_id stage_event_hash_id],
analytics_cycle_analytics_issue_stage_events: %w[author_id group_id issue_id milestone_id project_id stage_event_hash_id],
audit_events: %w[author_id entity_id target_id], audit_events: %w[author_id entity_id target_id],
award_emoji: %w[awardable_id user_id], award_emoji: %w[awardable_id user_id],
aws_roles: %w[role_external_id], aws_roles: %w[role_external_id],
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Analytics::CycleAnalytics::IssueStageEvent do
it { is_expected.to validate_presence_of(:stage_event_hash_id) }
it { is_expected.to validate_presence_of(:issue_id) }
it { is_expected.to validate_presence_of(:group_id) }
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:start_event_timestamp) }
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Analytics::CycleAnalytics::MergeRequestStageEvent do
it { is_expected.to validate_presence_of(:stage_event_hash_id) }
it { is_expected.to validate_presence_of(:merge_request_id) }
it { is_expected.to validate_presence_of(:group_id) }
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:start_event_timestamp) }
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