Merge branch 'pg_trgm_extension' into 'master'
Pg trgm extension enable Depends on gitlab-org/gitlab-ce!2987 See merge request !682
This commit is contained in:
commit
f88fe259ce
|
@ -24,7 +24,11 @@ If you are going to use MySQL/MariaDB, make sure to read the [MySQL special note
|
|||
## Using a non-packaged PostgreSQL database management server
|
||||
|
||||
If you do not want to use the packaged PostgreSQL server, you can configure an
|
||||
external one:
|
||||
omnibus-gitlab package to use an external one.
|
||||
|
||||
**WARNING** If you are using non-packaged PostgreSQL server, you need to make
|
||||
sure that PostgreSQL is setup according to the requirements, see
|
||||
[database requirements document] for more information.
|
||||
|
||||
1. Edit `/etc/gitlab/gitlab.rb`:
|
||||
|
||||
|
@ -195,3 +199,4 @@ sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql
|
|||
[Reconfigure GitLab]: http://doc.gitlab.com/ce/administration/restart_gitlab.html#omnibus-gitlab-reconfigure "Reconfigure GitLab"
|
||||
[rake-restore]: http://doc.gitlab.com/ce/raketasks/backup_restore.html#restore-a-previously-created-backup "Restore raketask documentation"
|
||||
[mysql-install]: http://doc.gitlab.com/ce/install/installation.html#database "MySQL documentation"
|
||||
[database requirements document]: http://doc.gitlab.com/ce/install/requirements.html#database
|
||||
|
|
|
@ -288,6 +288,7 @@ 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[enable pg_trgm extension]', :immediately unless postgresql_not_listening || !node['gitlab']['postgresql']['enable']
|
||||
notifies :run, 'bash[migrate gitlab-rails database]' unless postgresql_not_listening
|
||||
notifies :run, 'execute[clear the gitlab-rails cache]' unless redis_not_listening
|
||||
notifies :run, 'bash[generate assets]' if node['gitlab']['gitlab-rails']['gitlab_relative_url']
|
||||
|
|
|
@ -138,35 +138,35 @@ pg_helper = PgHelper.new(node)
|
|||
pg_port = node['gitlab']['postgresql']['port']
|
||||
bin_dir = "/opt/gitlab/embedded/bin"
|
||||
database_name = node['gitlab']['gitlab-rails']['db_database']
|
||||
ci_database_name = node['gitlab']['gitlab-ci']['db_database']
|
||||
gitlab_sql_user = node['gitlab']['postgresql']['sql_user']
|
||||
|
||||
databases = []
|
||||
if node['gitlab']['gitlab-rails']['enable']
|
||||
databases << ['gitlab-rails', database_name, node['gitlab']['postgresql']['sql_user']]
|
||||
end
|
||||
|
||||
if node['gitlab']['gitlab-ci']['enable']
|
||||
databases << ['gitlab-ci', ci_database_name, node['gitlab']['postgresql']['sql_ci_user']]
|
||||
end
|
||||
|
||||
databases.each do |rails_app, db_name, sql_user|
|
||||
execute "create #{sql_user} database user" do
|
||||
command "#{bin_dir}/psql --port #{pg_port} -h #{postgresql_socket_dir} -d template1 -c \"CREATE USER #{sql_user}\""
|
||||
execute "create #{gitlab_sql_user} database user" do
|
||||
command "#{bin_dir}/psql --port #{pg_port} -h #{postgresql_socket_dir} -d template1 -c \"CREATE USER #{gitlab_sql_user}\""
|
||||
user postgresql_user
|
||||
# Added retries to give the service time to start on slower systems
|
||||
retries 20
|
||||
not_if { !pg_helper.is_running? || pg_helper.user_exists?(sql_user) }
|
||||
not_if { !pg_helper.is_running? || pg_helper.user_exists?(gitlab_sql_user) }
|
||||
end
|
||||
|
||||
execute "create #{db_name} database" do
|
||||
command "#{bin_dir}/createdb --port #{pg_port} -h #{postgresql_socket_dir} -O #{sql_user} #{db_name}"
|
||||
execute "create #{database_name} database" do
|
||||
command "#{bin_dir}/createdb --port #{pg_port} -h #{postgresql_socket_dir} -O #{gitlab_sql_user} #{database_name}"
|
||||
user postgresql_user
|
||||
not_if { !pg_helper.is_running? || pg_helper.database_exists?(db_name) }
|
||||
retries 30
|
||||
notifies :run, "execute[initialize #{rails_app} database]", :immediately
|
||||
notifies :run, "execute[enable pg_trgm extension]", :immediately
|
||||
notifies :run, "execute[initialize gitlab-rails database]", :immediately
|
||||
not_if { !pg_helper.is_running? || pg_helper.database_exists?(database_name) }
|
||||
end
|
||||
end
|
||||
|
||||
execute "enable pg_trgm extension" do
|
||||
command "#{bin_dir}/psql --port #{pg_port} -h #{postgresql_socket_dir} -d #{database_name} -c \"CREATE EXTENSION IF NOT EXISTS pg_trgm;\""
|
||||
user postgresql_user
|
||||
retries 20
|
||||
action :nothing
|
||||
not_if { !pg_helper.is_running? }
|
||||
end
|
||||
|
||||
###
|
||||
# Create replication user
|
||||
###
|
||||
|
|
Loading…
Reference in New Issue