diff --git a/CHANGELOG.md b/CHANGELOG.md index b1001389bb02497e04c6fa6d65baf3701dde08bf..5ea239a0d25aca2d3c18f4520fa68a53a5e2512f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- [SQL dump migration can now be applied twice](https://gitlab.indiscale.com/caosdb/src/caosdb-mysqlbackend/-/issues/60): Fixed an error in the regex. + ### Security ## [8.0.0] - 2024-10-24 ## diff --git a/dump_updates/2024-10-02.dump_fix_mariadb_10_6.sh b/dump_updates/2024-10-02.dump_fix_mariadb_10_6.sh index 4450b831f47d1ba8787b87708b6b8e2ec3be6e8d..8b9e4843c349a9281526953d6e0c40712a2b1c1a 100755 --- a/dump_updates/2024-10-02.dump_fix_mariadb_10_6.sh +++ b/dump_updates/2024-10-02.dump_fix_mariadb_10_6.sh @@ -35,10 +35,10 @@ set -euo pipefail IFS=$'\n\t' script=' -s/Offset INT UNSIGNED) RETURNS varbinary(255)/HeadOffset INT UNSIGNED) RETURNS varbinary(255)/ +/^[[:blank:]]+Offset INT UNSIGNED/s/Offset INT UNSIGNED\) RETURNS varbinary\(255\)/HeadOffset INT UNSIGNED\) RETURNS varbinary(255)/ s/LIMIT 1 OFFSET Offset/LIMIT 1 OFFSET HeadOffset/ ' -sed -e "$script" +sed -E -e "$script" unset script diff --git a/dump_updates/test/test_all.py b/dump_updates/test/test_all.py index 8e97d2a1cea461dc0f5613a5ea94eeac663d5b3c..acdeeeceb341c396c91b764e60bd8b30a7bcd19d 100644 --- a/dump_updates/test/test_all.py +++ b/dump_updates/test/test_all.py @@ -19,6 +19,11 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. """Testing the dump update scripts + +As a general rule, dump updaters should be idempotent, so tests should run the update again after +the first checks are successlful. + +TODO: Reduce the boilerplate for the tests. """ import filecmp @@ -68,3 +73,13 @@ def test_2024_10_02(tmpdir): check=True ) assert filecmp.cmp(output.name, expectedfile), "Output does not match expected output." + with (NamedTemporaryFile(dir=tmpdir, suffix=".sql", delete=True) as output2, + open(output.name, mode="rb") as infile_stream + ): + run([script_fullname], + stdin=infile_stream, + stdout=output2, + check=True + ) + assert filecmp.cmp(output2.name, expectedfile), ( + "Run 2: Output does not match expected output.")