From 3978647e7e6b0ce62687adf5874c21e48da09e08 Mon Sep 17 00:00:00 2001 From: Shashank Tavildar Date: Fri, 9 Sep 2016 19:33:20 +0000 Subject: [PATCH] Enabled conversion of existing db and tables to utf8_general_ci [M->N] While upgrading from Mitaka to Newton, the db-collation-alter playbook attempts to convert the existing db and tables to utf8_general_ci but fails. The reason for this was because the FOREIGN_KEY_CHECKS variable in the playbook was being set/reset only for a particular session (i.e. a play) and once the play got over the variable was again reset to its default value(i.e. 1). This patch ensures that the foreign key checks are indeed disabled throughout the playbook by setting the global variable instead of the local one. Change-Id: Ifed6279fcb5f418c1e1a348739bcd50ade42464f Closes-Bug: #1621983 --- .../upgrade-utilities/playbooks/db-collation-alter.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade-utilities/playbooks/db-collation-alter.yml b/scripts/upgrade-utilities/playbooks/db-collation-alter.yml index ee16e7965a..3e7bb8a2bc 100644 --- a/scripts/upgrade-utilities/playbooks/db-collation-alter.yml +++ b/scripts/upgrade-utilities/playbooks/db-collation-alter.yml @@ -26,22 +26,22 @@ WHERE CCSA.collation_name = T.table_collation AND CCSA.CHARACTER_SET_NAME = 'utf8' AND CCSA.COLLATION_NAME = 'utf8_unicode_ci';" register: utf8_unicode_ci_tables - - name: Disable foreign key checks + - name: Disable global foreign key checks command: > mysql -e - "SET foreign_key_checks = 0;" + "SET GLOBAL FOREIGN_KEY_CHECKS = 0;" when: utf8_unicode_ci_tables.stdout_lines | length > 0 - name: Convert tables to utf8_general_ci collation command: > - mysql -e + mysql -e "ALTER TABLE {{ item.split()[1] }} CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" {{ item.split()[0] }} with_items: "{{ utf8_unicode_ci_tables.stdout_lines }}" when: item | search("^(?!table_schema)\w+\t\w+$") - - name: Enable foreign key checks + - name: Enable global foreign key checks command: > mysql -e - "SET foreign_key_checks = 1;" + "SET GLOBAL FOREIGN_KEY_CHECKS = 1;" when: utf8_unicode_ci_tables.stdout_lines | length > 0 - name: Find databases with utf8_unicode_ci collation command: >