Commit e883ccb2 authored by Michael Kozono's avatar Michael Kozono
Browse files

Fix migration for pre-Postgres 9.5

parent 0544a6c99380
......@@ -88,9 +88,14 @@ def insert_file_paths(file_paths)
end
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 (?, ?, ?)'
sql = if Gitlab::Database.postgresql?
sql = if postgresql?
"INSERT INTO #{table_columns_and_values} ON CONFLICT DO NOTHING;"
else
"INSERT IGNORE INTO #{table_columns_and_values};"
......@@ -101,6 +106,15 @@ def insert_file_path(file_path)
ActiveRecord::Base.connection.execute(sql)
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
bulk_queue_background_migration_jobs_by_range(UntrackedFile, FOLLOW_UP_MIGRATION)
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment