Commit 840b4c935af30859b23134454154e6c4dbbef7da

Authored by Jacob Vosmaer
1 parent 1064b242

Run `rake db:migrate` only on VERSION changes

CHANGELOG
... ... @@ -11,6 +11,7 @@
11 11 - Use more fancy SSL ciphers for Nginx
12 12 - Use sane LDAP defaults
13 13 - Clear the Rails cache after modifying gitlab.yml
  14 +- Only run `rake db:migrate` when the gitlab-rails version has changed
14 15  
15 16 6.8.1
16 17 - Use gitlab-rails 6.8.1
... ...
files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb
... ... @@ -20,9 +20,7 @@ execute "initialize database" do
20 20 action :nothing
21 21 end
22 22  
23   -user_group = "#{node['gitlab']['user']['username']}:#{node['gitlab']['user']['group']}"
24   -execute "chown #{user_group} /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb"
25   -
26 23 execute "migrate database" do
27 24 command "/opt/gitlab/bin/gitlab-rake db:migrate"
  25 + action :nothing
28 26 end
... ...
files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb
... ... @@ -114,6 +114,17 @@ end
114 114 end
115 115 end
116 116  
  117 +# Make schema.rb writable for when we run `rake db:migrate`
  118 +file "/opt/gitlab/embedded/service/gitlab-rails/db/schema.rb" do
  119 + owner node['gitlab']['user']['username']
  120 +end
  121 +
  122 +# Only run `rake db:migrate` when the gitlab-rails version has changed
  123 +remote_file File.join(gitlab_rails_dir, 'VERSION') do
  124 + source "file:///opt/gitlab/embedded/service/gitlab-rails/VERSION"
  125 + notifies :run, 'execute[migrate database]'
  126 +end
  127 +
117 128 execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-rails/public"
118 129  
119 130 execute "clear the gitlab-rails cache" do
... ...