Commit e6d0566e authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '37026-backend-create-a-table-for-sentry-error-related-issues' into 'master'

Backend: Create a table for sentry error related issues

See merge request gitlab-org/gitlab!20629
parents e9197899 a8bd1cf6
......@@ -42,6 +42,7 @@ class Issue < ApplicationRecord
has_many :issue_assignees
has_many :assignees, class_name: "User", through: :issue_assignees
has_many :zoom_meetings
has_one :sentry_issue
validates :project, presence: true
......
# frozen_string_literal: true
class SentryIssue < ApplicationRecord
belongs_to :issue
validates :issue, uniqueness: true, presence: true
validates :sentry_issue_identifier, presence: true
end
---
title: Add SentryIssue table to store a link between issue and sentry issue
merge_request: 37026
author:
type: added
# frozen_string_literal: true
class CreateSentryIssuesTable < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :sentry_issues do |t|
t.references :issue,
foreign_key: { on_delete: :cascade },
index: { unique: true },
null: false
t.bigint :sentry_issue_identifier, null: false
end
end
end
......@@ -3607,6 +3607,12 @@ ActiveRecord::Schema.define(version: 2019_12_06_122926) do
t.index ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true
end
create_table "sentry_issues", force: :cascade do |t|
t.bigint "issue_id", null: false
t.bigint "sentry_issue_identifier", null: false
t.index ["issue_id"], name: "index_sentry_issues_on_issue_id", unique: true
end
create_table "service_desk_settings", primary_key: "project_id", id: :bigint, default: nil, force: :cascade do |t|
t.string "issue_template_key", limit: 255
end
......@@ -4660,6 +4666,7 @@ ActiveRecord::Schema.define(version: 2019_12_06_122926) do
add_foreign_key "scim_oauth_access_tokens", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "self_managed_prometheus_alert_events", "environments", on_delete: :cascade
add_foreign_key "self_managed_prometheus_alert_events", "projects", on_delete: :cascade
add_foreign_key "sentry_issues", "issues", on_delete: :cascade
add_foreign_key "service_desk_settings", "projects", on_delete: :cascade
add_foreign_key "services", "projects", name: "fk_71cce407f9", on_delete: :cascade
add_foreign_key "slack_integrations", "services", on_delete: :cascade
......
......@@ -208,7 +208,7 @@ and it is useful for knowing which versions won't be compatible between them.
### When to bump the version up
We will have to bump the verision if we rename model/columns or perform any format
We will have to bump the version if we rename model/columns or perform any format
modifications in the JSON structure or the file structure of the archive file.
We do not need to bump the version up in any of the following cases:
......
......@@ -29,6 +29,7 @@ tree:
- :priorities
- :issue_assignees
- :zoom_meetings
- :sentry_issue
- snippets:
- :award_emoji
- notes:
......
# frozen_string_literal: true
FactoryBot.define do
factory :sentry_issue, class: SentryIssue do
issue
sentry_issue_identifier { 1234567891 }
end
end
......@@ -366,7 +366,12 @@
"type": "ProjectLabel"
}
}
]
],
"sentry_issue": {
"id": 1,
"issue_id": 40,
"sentry_issue_identifier": 1234567891
}
},
{
"id": 39,
......
......@@ -8,6 +8,7 @@ issues:
- milestone
- notes
- resource_label_events
- sentry_issue
- label_links
- labels
- last_edited_by
......@@ -548,4 +549,6 @@ versions: &version
- actions
zoom_meetings:
- issue
sentry_issue:
- issue
design_versions: *version
......@@ -234,6 +234,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(meetings.first.url).to eq('https://zoom.us/j/123456789')
end
it 'restores sentry issues' do
sentry_issue = @project.issues.first.sentry_issue
expect(sentry_issue.sentry_issue_identifier).to eq(1234567891)
end
context 'Merge requests' do
it 'always has the new project as a target' do
expect(MergeRequest.find_by_title('MR1').target_project).to eq(@project)
......
......@@ -689,6 +689,10 @@ ErrorTracking::ProjectErrorTrackingSetting:
- project_id
- project_name
- organization_name
SentryIssue:
- id
- issue_id
- sentry_issue_identifier
Suggestion:
- id
- note_id
......
......@@ -12,6 +12,7 @@ describe Issue do
it { is_expected.to belong_to(:duplicated_to).class_name('Issue') }
it { is_expected.to belong_to(:closed_by).class_name('User') }
it { is_expected.to have_many(:assignees) }
it { is_expected.to have_one(:sentry_issue) }
end
describe 'modules' do
......
# frozen_string_literal: true
require 'spec_helper'
describe SentryIssue do
describe 'associations' do
it { is_expected.to belong_to(:issue) }
end
describe 'validations' do
let!(:sentry_issue) { create(:sentry_issue) }
it { is_expected.to validate_presence_of(:issue) }
it { is_expected.to validate_uniqueness_of(:issue) }
it { is_expected.to validate_presence_of(:sentry_issue_identifier) }
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