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
44355f91
Commit
44355f91
authored
Jun 05, 2020
by
Andreas Brandl
Committed by
Adam Hegyi
Jun 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove explicit create for pgpsql extension
This is now unneeded since we're on >=PG11 now.
parent
ad256ac4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
24 deletions
+3
-24
db/structure.sql
db/structure.sql
+0
-2
lib/gitlab/database/schema_cleaner.rb
lib/gitlab/database/schema_cleaner.rb
+3
-15
spec/fixtures/gitlab/database/structure_example.sql
spec/fixtures/gitlab/database/structure_example.sql
+0
-1
spec/fixtures/gitlab/database/structure_example_cleaned.sql
spec/fixtures/gitlab/database/structure_example_cleaned.sql
+0
-2
spec/lib/gitlab/database/schema_cleaner_spec.rb
spec/lib/gitlab/database/schema_cleaner_spec.rb
+0
-4
No files found.
db/structure.sql
View file @
44355f91
SET
search_path
=
public
;
SET
search_path
=
public
;
CREATE
EXTENSION
IF
NOT
EXISTS
plpgsql
WITH
SCHEMA
pg_catalog
;
CREATE
EXTENSION
IF
NOT
EXISTS
pg_trgm
WITH
SCHEMA
public
;
CREATE
EXTENSION
IF
NOT
EXISTS
pg_trgm
WITH
SCHEMA
public
;
CREATE
TABLE
public
.
abuse_reports
(
CREATE
TABLE
public
.
abuse_reports
(
...
...
lib/gitlab/database/schema_cleaner.rb
View file @
44355f91
...
@@ -12,27 +12,15 @@ module Gitlab
...
@@ -12,27 +12,15 @@ module Gitlab
def
clean
(
io
)
def
clean
(
io
)
structure
=
original_schema
.
dup
structure
=
original_schema
.
dup
# Postgres compat fix for PG 9.6 (which doesn't support (AS datatype) syntax for sequences)
structure
.
gsub!
(
/CREATE SEQUENCE [^.]+\.\S+\n(\s+AS integer\n)/
)
{
|
m
|
m
.
gsub
(
Regexp
.
last_match
[
1
],
''
)
}
# Also a PG 9.6 compatibility fix, see below.
structure
.
gsub!
(
/^CREATE EXTENSION IF NOT EXISTS plpgsql.*/
,
''
)
structure
.
gsub!
(
/^COMMENT ON EXTENSION.*/
,
''
)
# Remove noise
# Remove noise
structure
.
gsub!
(
/^COMMENT ON EXTENSION.*/
,
''
)
structure
.
gsub!
(
/^SET.+/
,
''
)
structure
.
gsub!
(
/^SET.+/
,
''
)
structure
.
gsub!
(
/^SELECT pg_catalog\.set_config\('search_path'.+/
,
''
)
structure
.
gsub!
(
/^SELECT pg_catalog\.set_config\('search_path'.+/
,
''
)
structure
.
gsub!
(
/^--.*/
,
"
\n
"
)
structure
.
gsub!
(
/^--.*/
,
"
\n
"
)
structure
.
gsub!
(
/\n{3,}/
,
"
\n\n
"
)
io
<<
"SET search_path=public;
\n\n
"
structure
=
"SET search_path=public;
\n
"
+
structure
# Adding plpgsql explicitly is again a compatibility fix for PG 9.6
structure
.
gsub!
(
/\n{3,}/
,
"
\n\n
"
)
# In more recent versions of pg_dump, the extension isn't explicitly dumped anymore.
# We use PG 9.6 still on CI and for schema checks - here this is still the case.
io
<<
<<~
SQL
.
strip
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
SQL
io
<<
structure
io
<<
structure
...
...
spec/fixtures/gitlab/database/structure_example.sql
View file @
44355f91
...
@@ -48,7 +48,6 @@ CREATE TABLE public.abuse_reports (
...
@@ -48,7 +48,6 @@ CREATE TABLE public.abuse_reports (
--
--
CREATE
SEQUENCE
public
.
abuse_reports_id_seq
CREATE
SEQUENCE
public
.
abuse_reports_id_seq
AS
integer
START
WITH
1
START
WITH
1
INCREMENT
BY
1
INCREMENT
BY
1
NO
MINVALUE
NO
MINVALUE
...
...
spec/fixtures/gitlab/database/structure_example_cleaned.sql
View file @
44355f91
SET
search_path
=
public
;
SET
search_path
=
public
;
CREATE
EXTENSION
IF
NOT
EXISTS
plpgsql
WITH
SCHEMA
pg_catalog
;
CREATE
EXTENSION
IF
NOT
EXISTS
pg_trgm
WITH
SCHEMA
public
;
CREATE
EXTENSION
IF
NOT
EXISTS
pg_trgm
WITH
SCHEMA
public
;
CREATE
TABLE
public
.
abuse_reports
(
CREATE
TABLE
public
.
abuse_reports
(
...
...
spec/lib/gitlab/database/schema_cleaner_spec.rb
View file @
44355f91
...
@@ -15,10 +15,6 @@ describe Gitlab::Database::SchemaCleaner do
...
@@ -15,10 +15,6 @@ describe Gitlab::Database::SchemaCleaner do
expect
(
subject
).
not_to
include
(
'COMMENT ON EXTENSION'
)
expect
(
subject
).
not_to
include
(
'COMMENT ON EXTENSION'
)
end
end
it
'includes the plpgsql extension'
do
expect
(
subject
).
to
include
(
'CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;'
)
end
it
'sets the search_path'
do
it
'sets the search_path'
do
expect
(
subject
.
split
(
"
\n
"
).
first
).
to
eq
(
'SET search_path=public;'
)
expect
(
subject
.
split
(
"
\n
"
).
first
).
to
eq
(
'SET search_path=public;'
)
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