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
e0c78f31
Commit
e0c78f31
authored
Feb 23, 2021
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using a boolean
Update migrations and schema Update code and specs
parent
2b95ed39
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
15 deletions
+15
-15
db/migrate/20210222030537_add_removed_at_to_oncall_participant.rb
...te/20210222030537_add_removed_at_to_oncall_participant.rb
+2
-4
db/migrate/20210222042745_add_removed_at_to_oncall_participant_index.rb
...10222042745_add_removed_at_to_oncall_participant_index.rb
+5
-3
db/structure.sql
db/structure.sql
+2
-2
ee/app/models/incident_management/oncall_participant.rb
ee/app/models/incident_management/oncall_participant.rb
+3
-3
ee/spec/factories/incident_management/oncall_participant.rb
ee/spec/factories/incident_management/oncall_participant.rb
+1
-1
ee/spec/models/incident_management/oncall_participant_spec.rb
...pec/models/incident_management/oncall_participant_spec.rb
+2
-2
No files found.
db/migrate/20210222030537_add_removed_at_to_oncall_participant.rb
View file @
e0c78f31
...
...
@@ -7,13 +7,11 @@ class AddRemovedAtToOncallParticipant < ActiveRecord::Migration[6.0]
def
up
with_lock_retries
do
add_column
:incident_management_oncall_participants
,
:
removed_at
,
:datetime_with_timezon
e
add_column
:incident_management_oncall_participants
,
:
is_removed
,
:boolean
,
default:
fals
e
end
end
def
down
remove_column
:incident_management_oncall_participants
,
:
removed_at
remove_column
:incident_management_oncall_participants
,
:
is_removed
end
end
db/migrate/20210222042745_add_removed_at_to_oncall_participant_index.rb
View file @
e0c78f31
...
...
@@ -3,14 +3,16 @@
class
AddRemovedAtToOncallParticipantIndex
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
DOWNTIME
=
false
INDEX_NAME
=
'index_incident_management_oncall_participants_is_removed'
def
up
add_concurrent_index
:incident_management_oncall_participants
,
:
removed_at
add_concurrent_index
:incident_management_oncall_participants
,
:
is_removed
,
name:
INDEX_NAME
end
def
down
remove_concurrent_index
:incident_management_oncall_participants
,
:removed_at
remove_concurrent_index
_by_name
(
:incident_management_oncall_participants
,
INDEX_NAME
)
end
end
db/structure.sql
View file @
e0c78f31
...
...
@@ -13234,7 +13234,7 @@ CREATE TABLE incident_management_oncall_participants (
user_id bigint NOT NULL,
color_palette smallint NOT NULL,
color_weight smallint NOT NULL,
removed_at timestamp with time zon
e
is_removed boolean DEFAULT fals
e
);
CREATE SEQUENCE incident_management_oncall_participants_id_seq
...
...
@@ -22461,7 +22461,7 @@ CREATE UNIQUE INDEX index_inc_mgmnt_oncall_rotations_on_oncall_schedule_id_and_n
CREATE INDEX index_incident_management_oncall_schedules_on_project_id ON incident_management_oncall_schedules USING btree (project_id);
CREATE INDEX index_incident_management_oncall_shifts_on_participant_id ON incident_management_oncall_shifts USING btree (participant_id);
CREATE INDEX index_incident_management_oncall_participants_
on_removed_at ON incident_management_oncall_participants USING btree (removed_at
);
CREATE INDEX index_incident_management_oncall_participants_
is_removed ON incident_management_oncall_participants USING btree (is_removed
);
CREATE UNIQUE INDEX index_index_statuses_on_project_id ON index_statuses USING btree (project_id);
ee/app/models/incident_management/oncall_participant.rb
View file @
e0c78f31
...
...
@@ -21,11 +21,11 @@ module IncidentManagement
delegate
:project
,
to: :rotation
,
allow_nil:
true
scope
:not_removed
,
->
{
where
(
removed_at:
nil
)
}
scope
:removed
,
->
{
where
(
'removed_at is NOT NULL'
)
}
scope
:not_removed
,
->
{
where
(
is_removed:
false
)
}
scope
:removed
,
->
{
where
(
is_removed:
true
)
}
def
mark_as_removed
update_column
(
:
removed_at
,
Time
.
current
)
update_column
(
:
is_removed
,
true
)
end
end
end
ee/spec/factories/incident_management/oncall_participant.rb
View file @
e0c78f31
...
...
@@ -14,7 +14,7 @@ FactoryBot.define do
end
trait
:removed
do
removed_at
{
Time
.
current
}
is_removed
{
true
}
end
end
end
ee/spec/models/incident_management/oncall_participant_spec.rb
View file @
e0c78f31
...
...
@@ -62,8 +62,8 @@ RSpec.describe IncidentManagement::OncallParticipant do
subject
{
participant
.
mark_as_removed
}
it
'updates
removed_at
to the current time'
do
expect
{
subject
}.
to
change
{
participant
.
reload
.
removed_at
}.
to
(
Time
.
current
)
it
'updates
is_removed
to the current time'
do
expect
{
subject
}.
to
change
{
participant
.
reload
.
is_removed
}.
to
(
true
)
end
end
...
...
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