Commit 840b4c935af30859b23134454154e6c4dbbef7da
1 parent
1064b242
Exists in
master
and in
11 other branches
Run `rake db:migrate` only on VERSION changes
Showing
3 changed files
with
13 additions
and
3 deletions
Show diff stats
CHANGELOG
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | - Use more fancy SSL ciphers for Nginx | 11 | - Use more fancy SSL ciphers for Nginx |
12 | - Use sane LDAP defaults | 12 | - Use sane LDAP defaults |
13 | - Clear the Rails cache after modifying gitlab.yml | 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 | 6.8.1 | 16 | 6.8.1 |
16 | - Use gitlab-rails 6.8.1 | 17 | - Use gitlab-rails 6.8.1 |
files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb
@@ -20,9 +20,7 @@ execute "initialize database" do | @@ -20,9 +20,7 @@ execute "initialize database" do | ||
20 | action :nothing | 20 | action :nothing |
21 | end | 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 | execute "migrate database" do | 23 | execute "migrate database" do |
27 | command "/opt/gitlab/bin/gitlab-rake db:migrate" | 24 | command "/opt/gitlab/bin/gitlab-rake db:migrate" |
25 | + action :nothing | ||
28 | end | 26 | end |
files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb
@@ -114,6 +114,17 @@ end | @@ -114,6 +114,17 @@ end | ||
114 | end | 114 | end |
115 | end | 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 | execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-rails/public" | 128 | execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-rails/public" |
118 | 129 | ||
119 | execute "clear the gitlab-rails cache" do | 130 | execute "clear the gitlab-rails cache" do |