Schema tidying following recent changes
cover Schema tidying following recent changes
We make mg-schema-test-database work again. Also, we make testid be NOT NULL. (Everything sets it and has done almost forever.)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/3 mg-schema-test-database: Apply updates, regardless of compatibility
The test database should be just like the real one, even if the schema compatibility looks wrong. So pass -ff to mg-schema-update.
--- mg-schema-test-database | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mg-schema-test-database +1 -1
@@ -411,7 +411,7 @@ END END withtest ./mg-schema-create -q --no-updates - withtest ./mg-schema-update -q apply $wantupdates + withtest ./mg-schema-update -qff apply $wantupdates printf " (seqs)" seq_alters=""
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/3 mg-schema-test-database: New --max-flight option
In reply to Ian JacksonThis can be useful when testing things which involve old data, rather than things which just involve new data.
--- mg-schema-test-database | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mg-schema-test-database +8 -2
@@ -4,7 +4,7 @@ # # # ./mg-schema-test-database create [_SUFFIX] [TASK...] \ -# [-fMINFLIGHT | -f-NUMFLIGHTS] \ +# [-fMINFLIGHT | -f-NUMFLIGHTS] [--max-flight=MAXFLIGHT] \ # [-hCTRL_DAEMONS_HOST] [-fOWNER_D_PORT[,QUEUE_D_PORT]] # # does `drop' and then creates
@@ -231,6 +231,7 @@ create) tasks='' minflight=-100 + maxflightcond='1=1' for arg in "$@"; do case "$arg" in *@*)
@@ -251,6 +252,9 @@ create) ;; _*) suffix="$arg" ;; + --max-flight=*) + maxflightcond="flight <= ${arg#*=}" + ;; -f*) minflight="${arg#-f}" ;; -h*) ctrlhost="${arg#-h}"
@@ -471,7 +475,9 @@ END schema_updates) continue ;; esac case " $ftables " in - *" $table "*) condition="flight >= $minflight" ;; + *" $table "*) + condition="flight >= $minflight AND $maxflightcond" + ;; *) condition="1=1" ;; esac each_copy_table $table "$condition"
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/3 db schema: Make the testid column NOT NLLL
In reply to Ian JacksonWe have to fix some old data. We insist that the old data is indeed old (more than 5 years old) and not part of proper flights (ie, blessed "play" or "crashed" or "unknown").
--- schema/testid-constraint.sql | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 schema/testid-constraint.sql
schema/testid-constraint.sql new file +28 -0
@@ -0,0 +1,28 @@ +-- ##OSSTEST## 005 Harmless +-- +-- All steps should have a testid. +-- Some very old data in our existing instances lacks this. +-- +-- The time_t value is Tue Jul 3 17:09:12 BST 2012, 5 years ago. + +WITH cutoff AS + (SELECT 1341331754) +UPDATE steps + SET testid = 'xxx-dumy-testid.' || stepno + WHERE testid IS NULL + AND ( + WITH f AS + (SELECT * FROM flights WHERE flights.flight = steps.flight) + SELECT + ( ((SELECT blessing FROM f) = 'unknown' + OR (SELECT blessing FROM f) = 'play' + OR (SELECT blessing FROM f) = 'crashed') + ) + AND (SELECT started FROM f) < (SELECT * FROM cutoff) + AND COALESCE( steps.flight < + (SELECT min(flight) FROM flights + WHERE started >= (SELECT * FROM cutoff)) + , 1=1 ) + ); + +ALTER TABLE steps ALTER COLUMN testid SET NOT NULL;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel