From 840b4c935af30859b23134454154e6c4dbbef7da Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 21 May 2014 10:30:39 +0200 Subject: [PATCH] Run `rake db:migrate` only on VERSION changes --- CHANGELOG | 1 + files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb | 4 +--- files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 02da40c..b23efe0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ - Use more fancy SSL ciphers for Nginx - Use sane LDAP defaults - Clear the Rails cache after modifying gitlab.yml +- Only run `rake db:migrate` when the gitlab-rails version has changed 6.8.1 - Use gitlab-rails 6.8.1 diff --git a/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb b/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb index e6686e7..1b2452e 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb @@ -20,9 +20,7 @@ execute "initialize database" do action :nothing end -user_group = "#{node['gitlab']['user']['username']}:#{node['gitlab']['user']['group']}" -execute "chown #{user_group} /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb" - execute "migrate database" do command "/opt/gitlab/bin/gitlab-rake db:migrate" + action :nothing end diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb index ffb112a..e8d3b6e 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb @@ -114,6 +114,17 @@ end end end +# Make schema.rb writable for when we run `rake db:migrate` +file "/opt/gitlab/embedded/service/gitlab-rails/db/schema.rb" do + owner node['gitlab']['user']['username'] +end + +# Only run `rake db:migrate` when the gitlab-rails version has changed +remote_file File.join(gitlab_rails_dir, 'VERSION') do + source "file:///opt/gitlab/embedded/service/gitlab-rails/VERSION" + notifies :run, 'execute[migrate database]' +end + execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-rails/public" execute "clear the gitlab-rails cache" do -- libgit2 0.21.2