Commit f1d32a9b061eb26aea13213067dea3f2f23ca2aa

Authored by Jacob Vosmaer
2 parents 242040c1 a678d8be

Merge branch 'db_migrations' into 'master'

DB Migrations
files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +#
  2 +# Copyright:: Copyright (c) 2014 GitLab.com
  3 +# License:: Apache License, Version 2.0
  4 +#
  5 +# Licensed under the Apache License, Version 2.0 (the "License");
  6 +# you may not use this file except in compliance with the License.
  7 +# You may obtain a copy of the License at
  8 +#
  9 +# http://www.apache.org/licenses/LICENSE-2.0
  10 +#
  11 +# Unless required by applicable law or agreed to in writing, software
  12 +# distributed under the License is distributed on an "AS IS" BASIS,
  13 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +# See the License for the specific language governing permissions and
  15 +# limitations under the License.
  16 +#
  17 +
  18 +execute "initialize database" do
  19 + command "/opt/gitlab/bin/gitlab-rake db:schema:load db:seed_fu"
  20 + action :nothing
  21 +end
  22 +
  23 +user_group = "#{node['gitlab']['user']['username']}:#{node['gitlab']['user']['group']}"
  24 +execute "chown #{user_group} /opt/gitlab/embedded/service/gitlab-core/db/schema.rb"
  25 +
  26 +execute "migrate database" do
  27 + command "/opt/gitlab/bin/gitlab-rake db:migrate"
  28 +end
... ...
files/gitlab-cookbooks/gitlab/recipes/default.rb
... ... @@ -60,8 +60,8 @@ include_recipe "runit"
60 60  
61 61 # Configure Services
62 62 [
63   - "postgresql",
64 63 "redis",
  64 + "postgresql", # Postgresql depends on Redis because of `rake db:seed_fu`
65 65 "unicorn",
66 66 "bootstrap",
67 67 ].each do |service|
... ... @@ -71,3 +71,5 @@ include_recipe "runit"
71 71 include_recipe "gitlab::#{service}_disable"
72 72 end
73 73 end
  74 +
  75 +include_recipe "gitlab::database_migrations"
... ...
files/gitlab-cookbooks/gitlab/recipes/postgresql.rb
... ... @@ -153,5 +153,5 @@ execute "create #{db_name} database" do
153 153 user pg_user
154 154 not_if { !pg_helper.is_running? || pg_helper.database_exists?(db_name) }
155 155 retries 30
156   - # notifies :run, "execute[migrate_database]", :immediately
  156 + notifies :run, "execute[initialize database]", :immediately
157 157 end
... ...