Skip to content
Snippets Groups Projects
Commit 15596db7 authored by DJ Mountney's avatar DJ Mountney :red_circle:
Browse files

Merge branch 'seperate-ctype-and-collate-pg-upgrade' into 'master'

Support seperate ctype and collate for pg-upgrade

Closes #4393

See merge request !3371
parents 42a39db4 2121cc31
No related branches found
No related tags found
1 merge request!3371Support seperate ctype and collate for pg-upgrade
---
title: Support pg-upgrade on dbs with collate and ctype values that differ from each
other
merge_request: 3371
author:
type: fixed
......@@ -64,6 +64,10 @@ module GitlabCtl
run_query('SHOW LC_COLLATE')
end
def fetch_lc_ctype
run_query('SHOW LC_CTYPE')
end
def fetch_server_encoding
run_query('SHOW SERVER_ENCODING')
end
......
......@@ -157,13 +157,13 @@ end
def common_pre_upgrade
maintenance_mode('enable')
locale, encoding = get_locale_encoding
locale, collate, encoding = get_locale_encoding
@db_worker.tmp_data_dir
stop_database
create_links(upgrade_version)
create_temp_data_dir
initialize_new_db(locale, encoding)
initialize_new_db(locale, collate, encoding)
end
def common_post_upgrade
......@@ -223,7 +223,8 @@ end
def get_locale_encoding
begin
locale = @db_worker.fetch_lc_collate
locale = @db_worker.fetch_lc_ctype
collate = @db_worker.fetch_lc_collate
encoding = @db_worker.fetch_server_encoding
rescue GitlabCtl::Errors::ExecutionError => ee
log 'There wasn an error fetching locale and encoding information from the database'
......@@ -232,7 +233,7 @@ def get_locale_encoding
log "STDERR: #{ee.stderr}"
end
[locale, encoding]
[locale, collate, encoding]
end
def create_temp_data_dir
......@@ -254,7 +255,7 @@ def create_temp_data_dir
end
end
def initialize_new_db(locale, encoding)
def initialize_new_db(locale, collate, encoding)
unless progress_message('Initializing the new database') do
begin
@db_worker.run_pg_command(
......@@ -262,7 +263,7 @@ def initialize_new_db(locale, encoding)
"-D #{@db_worker.tmp_data_dir}.#{upgrade_version.major} " \
"--locale #{locale} " \
"--encoding #{encoding} " \
" --lc-collate=#{locale} " \
" --lc-collate=#{collate} " \
"--lc-ctype=#{locale}"
)
rescue GitlabCtl::Errors::ExecutionError => ee
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment