MT#57270 Create triggers after data inserts

There are 'after insert' triggers so if they are created before data
they can mess up with data.

Change-Id: Id14b5ce333143d48423e9f8b08746cf1846c6cde
mr11.4
Mykola Malkov 3 years ago
parent 8f6ae65b3d
commit 9dc3ac4185

@ -97,7 +97,7 @@ for schema in "${schemes[@]}"; do
echo "CREATE DATABASE ${schema};" >> "${schema}.sql"
echo "USE ${schema};" >> "${schema}.sql"
mysqldump "${schema}" --triggers --routines --compact --no-data \
mysqldump "${schema}" --skip-triggers --routines --compact --no-data \
-S "${mariadb_dir}/mysqld.sock" \
>> "${schema}.sql"
@ -105,6 +105,10 @@ for schema in "${schemes[@]}"; do
-S "${mariadb_dir}/mysqld.sock" \
> "${schema}_data.sql"
mysqldump "${schema}" --no-data --no-create-info --triggers --compact \
-S "${mariadb_dir}/mysqld.sock" \
> "${schema}_triggers.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"
@ -112,6 +116,10 @@ for schema in "${schemes[@]}"; do
cat "${schema}_data.sql" >> "${schema}.sql"
rm -f "${schema}_data.sql"
# We need to create triggers after data so they won't mess up the data
cat "${schema}_triggers.sql" >> "${schema}.sql"
rm -f "${schema}_triggers.sql"
echo "COMMIT;" >> "${schema}.sql"
echo "Done"
done

Loading…
Cancel
Save