--- /dev/null
+-- ##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;