Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4ed23ba8
Commit
4ed23ba8
authored
Jul 21, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issue_type to Issues
- Add index - Enum type
parent
85d00751
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
1 deletion
+66
-1
app/models/issue.rb
app/models/issue.rb
+6
-0
changelogs/unreleased/222954-add-issue-type-to-issues.yml
changelogs/unreleased/222954-add-issue-type-to-issues.yml
+5
-0
db/migrate/20200721034536_add_issue_type_to_issues.rb
db/migrate/20200721034536_add_issue_type_to_issues.rb
+10
-0
db/migrate/20200721043502_add_issue_type_index_to_issues.rb
db/migrate/20200721043502_add_issue_type_index_to_issues.rb
+17
-0
db/structure.sql
db/structure.sql
+3
-1
spec/factories/issues.rb
spec/factories/issues.rb
+5
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+20
-0
No files found.
app/models/issue.rb
View file @
4ed23ba8
...
...
@@ -68,6 +68,12 @@ class Issue < ApplicationRecord
accepts_nested_attributes_for
:sentry_issue
validates
:project
,
presence:
true
validates
:issue_type
,
presence:
true
enum
issue_type:
{
issue:
0
,
incident:
1
}
alias_attribute
:parent_ids
,
:project_id
alias_method
:issuing_parent
,
:project
...
...
changelogs/unreleased/222954-add-issue-type-to-issues.yml
0 → 100644
View file @
4ed23ba8
---
title
:
Add issue_type column to issues table
merge_request
:
37402
author
:
type
:
added
db/migrate/20200721034536_add_issue_type_to_issues.rb
0 → 100644
View file @
4ed23ba8
# frozen_string_literal: true
class
AddIssueTypeToIssues
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
change
# Set default to issue type
add_column
:issues
,
:issue_type
,
:integer
,
limit:
2
,
default:
0
end
end
db/migrate/20200721043502_add_issue_type_index_to_issues.rb
0 → 100644
View file @
4ed23ba8
# frozen_string_literal: true
class
AddIssueTypeIndexToIssues
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_index
:issues
,
:issue_type
end
def
down
remove_concurrent_index
:issues
,
:issue_type
end
end
db/structure.sql
View file @
4ed23ba8
...
...
@@ -12527,7 +12527,7 @@ CREATE TABLE public.issues (
health_status
smallint
,
external_key
character
varying
(
255
),
sprint_id
bigint
,
CONSTRAINT
check_fba63f706d
CHECK
((
lock_version
IS
NOT
NULL
))
issue_type
smallint
DEFAULT
0
);
CREATE
SEQUENCE
public
.
issues_id_seq
...
...
@@ -19696,6 +19696,8 @@ CREATE INDEX index_issues_on_description_trigram ON public.issues USING gin (des
CREATE
INDEX
index_issues_on_duplicated_to_id
ON
public
.
issues
USING
btree
(
duplicated_to_id
)
WHERE
(
duplicated_to_id
IS
NOT
NULL
);
CREATE
INDEX
index_issues_on_issue_type
ON
public
.
issues
USING
btree
(
issue_type
);
CREATE
INDEX
index_issues_on_last_edited_by_id
ON
public
.
issues
USING
btree
(
last_edited_by_id
);
CREATE
INDEX
index_issues_on_milestone_id
ON
public
.
issues
USING
btree
(
milestone_id
);
...
...
spec/factories/issues.rb
View file @
4ed23ba8
...
...
@@ -7,6 +7,7 @@ FactoryBot.define do
author
{
project
.
creator
}
updated_by
{
author
}
relative_position
{
RelativePositioning
::
START_POSITION
}
issue_type
{
:issue
}
trait
:confidential
do
confidential
{
true
}
...
...
@@ -41,5 +42,9 @@ FactoryBot.define do
issue
.
update!
(
labels:
evaluator
.
labels
)
end
end
factory
:incident
do
issue_type
{
:incident
}
end
end
end
spec/models/issue_spec.rb
View file @
4ed23ba8
...
...
@@ -58,6 +58,26 @@ RSpec.describe Issue do
end
end
describe
'validations'
do
subject
{
issue
.
valid?
}
describe
'issue_type'
do
let
(
:issue
)
{
build
(
:issue
,
issue_type:
issue_type
)
}
context
'when a valid type'
do
let
(
:issue_type
)
{
:issue
}
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'empty type'
do
let
(
:issue_type
)
{
nil
}
it
{
is_expected
.
to
eq
(
false
)
}
end
end
end
subject
{
create
(
:issue
)
}
describe
'callbacks'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment