summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 12:09:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 12:09:22 +0000
commit286fe61013674fe2d245ffc8d2233baf09923e70 (patch)
tree2037291f5863105e54e75be056b49f7d62007cae /lib
parent4cb5e5011abfe8d50ac3a7ebd0018c563c6d7af4 (diff)
downloadgitlab-ce-286fe61013674fe2d245ffc8d2233baf09923e70.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/link_lfs_objects_projects.rb82
-rw-r--r--lib/gitlab/ci/templates/Pages/Jekyll.gitlab-ci.yml3
-rw-r--r--lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml2
-rw-r--r--lib/gitlab/ci/templates/Pages/Nanoc.gitlab-ci.yml2
-rw-r--r--lib/gitlab/ci/templates/Pages/Octopress.gitlab-ci.yml2
5 files changed, 87 insertions, 4 deletions
diff --git a/lib/gitlab/background_migration/link_lfs_objects_projects.rb b/lib/gitlab/background_migration/link_lfs_objects_projects.rb
new file mode 100644
index 00000000000..983470c5121
--- /dev/null
+++ b/lib/gitlab/background_migration/link_lfs_objects_projects.rb
@@ -0,0 +1,82 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Create missing LfsObjectsProject records for forks
+ class LinkLfsObjectsProjects
+ # Model specifically used for migration.
+ class LfsObjectsProject < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'lfs_objects_projects'
+
+ def self.linkable
+ where(
+ <<~SQL
+ lfs_objects_projects.project_id IN (
+ SELECT fork_network_members.forked_from_project_id
+ FROM fork_network_members
+ WHERE fork_network_members.forked_from_project_id IS NOT NULL
+ )
+ SQL
+ )
+ end
+ end
+
+ # Model specifically used for migration.
+ class ForkNetworkMember < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'fork_network_members'
+
+ def self.without_lfs_object(lfs_object_id)
+ where(
+ <<~SQL
+ fork_network_members.project_id NOT IN (
+ SELECT lop.project_id
+ FROM lfs_objects_projects lop
+ WHERE lop.lfs_object_id = #{lfs_object_id}
+ )
+ SQL
+ )
+ end
+ end
+
+ BATCH_SIZE = 1000
+
+ def perform(start_id, end_id)
+ lfs_objects_projects =
+ Gitlab::BackgroundMigration::LinkLfsObjectsProjects::LfsObjectsProject
+ .linkable
+ .where(id: start_id..end_id)
+
+ return if lfs_objects_projects.empty?
+
+ lfs_objects_projects.find_each do |lop|
+ ForkNetworkMember
+ .select("#{lop.lfs_object_id}, fork_network_members.project_id, NOW(), NOW()")
+ .without_lfs_object(lop.lfs_object_id)
+ .where(forked_from_project_id: lop.project_id)
+ .each_batch(of: BATCH_SIZE) do |batch, index|
+ execute <<~SQL
+ INSERT INTO lfs_objects_projects (lfs_object_id, project_id, created_at, updated_at)
+ #{batch.to_sql}
+ SQL
+
+ logger.info(message: "LinkLfsObjectsProjects: created missing LfsObjectsProject records for LfsObject #{lop.lfs_object_id}")
+ end
+ end
+ end
+
+ private
+
+ def execute(sql)
+ ::ActiveRecord::Base.connection.execute(sql)
+ end
+
+ def logger
+ @logger ||= Gitlab::BackgroundMigration::Logger.build
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/ci/templates/Pages/Jekyll.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Jekyll.gitlab-ci.yml
index e7dacd3a1fc..0c8859dc779 100644
--- a/lib/gitlab/ci/templates/Pages/Jekyll.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Pages/Jekyll.gitlab-ci.yml
@@ -1,12 +1,13 @@
# Template project: https://gitlab.com/pages/jekyll
# Docs: https://docs.gitlab.com/ce/pages/
-image: ruby:2.3
+image: ruby:2.6
variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8
before_script:
+ - gem install bundler
- bundle install
test:
diff --git a/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml
index 57ac323dfdf..462b4737c4e 100644
--- a/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml
@@ -1,5 +1,5 @@
# Full project: https://gitlab.com/pages/middleman
-image: ruby:2.3
+image: ruby:2.6
cache:
paths:
diff --git a/lib/gitlab/ci/templates/Pages/Nanoc.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Nanoc.gitlab-ci.yml
index 7f037b5f5cf..b512f8d77e9 100644
--- a/lib/gitlab/ci/templates/Pages/Nanoc.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Pages/Nanoc.gitlab-ci.yml
@@ -1,5 +1,5 @@
# Full project: https://gitlab.com/pages/nanoc
-image: ruby:2.3
+image: ruby:2.6
pages:
script:
diff --git a/lib/gitlab/ci/templates/Pages/Octopress.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Octopress.gitlab-ci.yml
index 6d912a89bc1..4318aadcaa6 100644
--- a/lib/gitlab/ci/templates/Pages/Octopress.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Pages/Octopress.gitlab-ci.yml
@@ -1,5 +1,5 @@
# Full project: https://gitlab.com/pages/octopress
-image: ruby:2.3
+image: ruby:2.6
pages:
script: