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
beec34d5
Commit
beec34d5
authored
May 27, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'iterations_add_daterange_constraint' into 'master'"
This reverts merge request !32335
parent
5b905654
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
143 deletions
+9
-143
changelogs/unreleased/iterations_add_daterange_constraint.yml
...gelogs/unreleased/iterations_add_daterange_constraint.yml
+0
-5
db/migrate/20200515152649_enable_btree_gist_extension.rb
db/migrate/20200515152649_enable_btree_gist_extension.rb
+0
-13
db/migrate/20200515153633_iteration_date_range_constraint.rb
db/migrate/20200515153633_iteration_date_range_constraint.rb
+0
-39
db/structure.sql
db/structure.sql
+0
-10
spec/models/iteration_spec.rb
spec/models/iteration_spec.rb
+9
-76
No files found.
changelogs/unreleased/iterations_add_daterange_constraint.yml
deleted
100644 → 0
View file @
5b905654
---
title
:
Add btree_gist PGSQL extension and add DB constraints for Iteration date ranges
merge_request
:
32335
author
:
type
:
added
db/migrate/20200515152649_enable_btree_gist_extension.rb
deleted
100644 → 0
View file @
5b905654
# frozen_string_literal: true
class
EnableBtreeGistExtension
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
up
execute
'CREATE EXTENSION IF NOT EXISTS btree_gist'
end
def
down
execute
'DROP EXTENSION IF EXISTS btree_gist'
end
end
db/migrate/20200515153633_iteration_date_range_constraint.rb
deleted
100644 → 0
View file @
5b905654
# frozen_string_literal: true
class
IterationDateRangeConstraint
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
up
execute
<<~
SQL
ALTER TABLE sprints
ADD CONSTRAINT iteration_start_and_due_daterange_project_id_constraint
EXCLUDE USING gist
( project_id WITH =,
daterange(start_date, due_date, '[]') WITH &&
)
WHERE (project_id IS NOT NULL)
SQL
execute
<<~
SQL
ALTER TABLE sprints
ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint
EXCLUDE USING gist
( group_id WITH =,
daterange(start_date, due_date, '[]') WITH &&
)
WHERE (group_id IS NOT NULL)
SQL
end
def
down
execute
<<~
SQL
ALTER TABLE sprints
DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_project_id_constraint
SQL
execute
<<~
SQL
ALTER TABLE sprints
DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint
SQL
end
end
db/structure.sql
View file @
beec34d5
...
...
@@ -2,8 +2,6 @@ SET search_path=public;
CREATE
EXTENSION
IF
NOT
EXISTS
plpgsql
WITH
SCHEMA
pg_catalog
;
CREATE
EXTENSION
IF
NOT
EXISTS
btree_gist
WITH
SCHEMA
public
;
CREATE
EXTENSION
IF
NOT
EXISTS
pg_trgm
WITH
SCHEMA
public
;
CREATE
TABLE
public
.
abuse_reports
(
...
...
@@ -8428,12 +8426,6 @@ ALTER TABLE ONLY public.issue_user_mentions
ALTER
TABLE
ONLY
public
.
issues
ADD
CONSTRAINT
issues_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
public
.
sprints
ADD
CONSTRAINT
iteration_start_and_due_daterange_group_id_constraint
EXCLUDE
USING
gist
(
group_id
WITH
=
,
daterange
(
start_date
,
due_date
,
'[]'
::
text
)
WITH
&&
)
WHERE
((
group_id
IS
NOT
NULL
));
ALTER
TABLE
ONLY
public
.
sprints
ADD
CONSTRAINT
iteration_start_and_due_daterange_project_id_constraint
EXCLUDE
USING
gist
(
project_id
WITH
=
,
daterange
(
start_date
,
due_date
,
'[]'
::
text
)
WITH
&&
)
WHERE
((
project_id
IS
NOT
NULL
));
ALTER
TABLE
ONLY
public
.
jira_connect_installations
ADD
CONSTRAINT
jira_connect_installations_pkey
PRIMARY
KEY
(
id
);
...
...
@@ -13957,8 +13949,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200514000009
20200514000132
20200514000340
20200515152649
20200515153633
20200515155620
20200519115908
20200519171058
...
...
spec/models/iteration_spec.rb
View file @
beec34d5
...
...
@@ -46,10 +46,7 @@ describe Iteration do
end
context
'when dates overlap'
do
let
(
:start_date
)
{
5
.
days
.
from_now
}
let
(
:due_date
)
{
6
.
days
.
from_now
}
shared_examples_for
'overlapping dates'
do
context
'same group'
do
context
'when start_date is in range'
do
let
(
:start_date
)
{
5
.
days
.
from_now
}
let
(
:due_date
)
{
3
.
weeks
.
from_now
}
...
...
@@ -58,11 +55,6 @@ describe Iteration do
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
[
:base
]).
to
include
(
'Dates cannot overlap with other existing Iterations'
)
end
it
'is not valid even if forced'
do
subject
.
validate
# to generate iid/etc
expect
{
subject
.
save
(
validate:
false
)
}.
to
raise_exception
(
ActiveRecord
::
StatementInvalid
,
/
#{
constraint_name
}
/
)
end
end
context
'when end_date is in range'
do
...
...
@@ -73,84 +65,25 @@ describe Iteration do
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
[
:base
]).
to
include
(
'Dates cannot overlap with other existing Iterations'
)
end
it
'is not valid even if forced'
do
subject
.
validate
# to generate iid/etc
expect
{
subject
.
save
(
validate:
false
)
}.
to
raise_exception
(
ActiveRecord
::
StatementInvalid
,
/
#{
constraint_name
}
/
)
end
end
context
'when both overlap'
do
let
(
:start_date
)
{
5
.
days
.
from_now
}
let
(
:due_date
)
{
6
.
days
.
from_now
}
it
'is not valid'
do
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
[
:base
]).
to
include
(
'Dates cannot overlap with other existing Iterations'
)
end
it
'is not valid even if forced'
do
subject
.
validate
# to generate iid/etc
expect
{
subject
.
save
(
validate:
false
)
}.
to
raise_exception
(
ActiveRecord
::
StatementInvalid
,
/
#{
constraint_name
}
/
)
end
end
end
context
'group'
do
it_behaves_like
'overlapping dates'
do
let
(
:constraint_name
)
{
'iteration_start_and_due_daterange_group_id_constraint'
}
end
context
'different group'
do
let
(
:group
)
{
create
(
:group
)
}
it
{
is_expected
.
to
be_valid
}
it
'does not trigger exclusion constraints'
do
expect
{
subject
.
save
}.
not_to
raise_exception
end
end
context
'in a project'
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
build
(
:iteration
,
project:
project
,
start_date:
start_date
,
due_date:
due_date
)
}
it
{
is_expected
.
to
be_valid
}
context
'different group'
do
let
(
:start_date
)
{
5
.
days
.
from_now
}
let
(
:due_date
)
{
6
.
days
.
from_now
}
let
(
:group
)
{
create
(
:group
)
}
it
'does not trigger exclusion constraints'
do
expect
{
subject
.
save
}.
not_to
raise_exception
end
end
end
context
'project'
do
let_it_be
(
:existing_iteration
)
{
create
(
:iteration
,
project:
project
,
start_date:
4
.
days
.
from_now
,
due_date:
1
.
week
.
from_now
)
}
subject
{
build
(
:iteration
,
project:
project
,
start_date:
start_date
,
due_date:
due_date
)
}
it_behaves_like
'overlapping dates'
do
let
(
:constraint_name
)
{
'iteration_start_and_due_daterange_project_id_constraint'
}
end
context
'different project'
do
let
(
:project
)
{
create
(
:project
)
}
it
{
is_expected
.
to
be_valid
}
it
'does not trigger exclusion constraints'
do
expect
{
subject
.
save
}.
not_to
raise_exception
end
end
context
'in a group'
do
let
(
:group
)
{
create
(
:group
)
}
subject
{
build
(
:iteration
,
group:
group
,
start_date:
start_date
,
due_date:
due_date
)
}
it
{
is_expected
.
to
be_valid
}
it
'does not trigger exclusion constraints'
do
expect
{
subject
.
save
}.
not_to
raise_exception
end
end
it
{
is_expected
.
to
be_valid
}
end
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