From a7cc6b37920a50bd81d83044502429acfe86b0ff Mon Sep 17 00:00:00 2001 From: Mykola Malkov Date: Fri, 19 May 2023 14:01:21 +0300 Subject: [PATCH] MT#57270 Split dumping of DDL and data The DDL statements should be as precise as possible so don't change anything there. In data part we need to replace dates (which are different on every build) with some value, so use NOW() function. Change-Id: Ia731f2f6836de2d2770cfd148e402cc83db6182e --- build_utils/ngcp-build-schema-files | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/build_utils/ngcp-build-schema-files b/build_utils/ngcp-build-schema-files index a10d9031..d969158c 100755 --- a/build_utils/ngcp-build-schema-files +++ b/build_utils/ngcp-build-schema-files @@ -97,12 +97,21 @@ for schema in "${schemes[@]}"; do echo "CREATE DATABASE ${schema};" >> "${schema}.sql" echo "USE ${schema};" >> "${schema}.sql" - # Replace all the dates in format YYYY-MM-DD HH:MM:SS with NOW() function - mysqldump "${schema}" --triggers --routines --compact \ - --skip-extended-insert \ + mysqldump "${schema}" --triggers --routines --compact --no-data \ -S "${mariadb_dir}/mysqld.sock" \ - | sed -r "s/'[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}'/NOW()/g" \ >> "${schema}.sql" + + mysqldump "${schema}" --no-create-info --skip-triggers --compact --skip-extended-insert \ + -S "${mariadb_dir}/mysqld.sock" \ + > "${schema}_data.sql" + + # We need to replace all other current dates with NOW() function + sed -ri "s/'[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}'/NOW()/g" \ + "${schema}_data.sql" + + cat "${schema}_data.sql" >> "${schema}.sql" + rm -f "${schema}_data.sql" + echo "COMMIT;" >> "${schema}.sql" echo "Done" done