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
10c660be
Commit
10c660be
authored
Nov 15, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix migration for pre-Postgres 9.5
parent
7fd26434
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
lib/gitlab/background_migration/prepare_untracked_uploads.rb
lib/gitlab/background_migration/prepare_untracked_uploads.rb
+15
-1
No files found.
lib/gitlab/background_migration/prepare_untracked_uploads.rb
View file @
10c660be
...
@@ -88,9 +88,14 @@ module Gitlab
...
@@ -88,9 +88,14 @@ module Gitlab
end
end
def
insert_file_path
(
file_path
)
def
insert_file_path
(
file_path
)
if
postgresql_pre_9_5?
# No easy way to do ON CONFLICT DO NOTHING before Postgres 9.5 so just use Rails
return
UntrackedFile
.
where
(
path:
file_path
).
first_or_create
end
table_columns_and_values
=
'untracked_files_for_uploads (path, created_at, updated_at) VALUES (?, ?, ?)'
table_columns_and_values
=
'untracked_files_for_uploads (path, created_at, updated_at) VALUES (?, ?, ?)'
sql
=
if
Gitlab
::
Database
.
postgresql?
sql
=
if
postgresql?
"INSERT INTO
#{
table_columns_and_values
}
ON CONFLICT DO NOTHING;"
"INSERT INTO
#{
table_columns_and_values
}
ON CONFLICT DO NOTHING;"
else
else
"INSERT IGNORE INTO
#{
table_columns_and_values
}
;"
"INSERT IGNORE INTO
#{
table_columns_and_values
}
;"
...
@@ -101,6 +106,15 @@ module Gitlab
...
@@ -101,6 +106,15 @@ module Gitlab
ActiveRecord
::
Base
.
connection
.
execute
(
sql
)
ActiveRecord
::
Base
.
connection
.
execute
(
sql
)
end
end
def
postgresql?
@postgresql
||=
Gitlab
::
Database
.
postgresql?
end
def
postgresql_pre_9_5?
@postgresql_pre_9_5
||=
postgresql?
&&
ActiveRecord
::
Base
.
connection
.
select_value
(
'SHOW server_version_num'
).
to_i
<
90500
end
def
schedule_populate_untracked_uploads_jobs
def
schedule_populate_untracked_uploads_jobs
bulk_queue_background_migration_jobs_by_range
(
UntrackedFile
,
FOLLOW_UP_MIGRATION
)
bulk_queue_background_migration_jobs_by_range
(
UntrackedFile
,
FOLLOW_UP_MIGRATION
)
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