Megatest

Check-in [946a699475]
Login
Overview
Comment:Corrected db version mismatch issue from 1.70 to 1.80
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.80 | v1.8001
Files: files | file ages | folders
SHA1: 946a6994754aaf5cd6951c7fcb2401f23b79d49d
User & Date: mmgraham on 2022-12-02 16:54:00
Other Links: branch diff | manifest | tags
Context
2022-12-07
10:38
fixed a typo in db:cautious-open-db check-in: 49e9838ddb user: mmgraham tags: v1.80
2022-12-02
16:54
Corrected db version mismatch issue from 1.70 to 1.80 check-in: 946a699475 user: mmgraham tags: v1.80, v1.8001
11:57
new version branch check-in: 6cb6675102 user: mmgraham tags: v1.80
Changes

Modified common.scm from [5559976353] to [fbb8aaa40e].

406
407
408
409
410
411
412



413

414
415







416
417
418
419
420
421
422
406
407
408
409
410
411
412
413
414
415
416
417


418
419
420
421
422
423
424
425
426
427
428
429
430
431







+
+
+

+
-
-
+
+
+
+
+
+
+







(define (common:version-db-delta)
  (- megatest-version (common:get-last-run-version-number)))

(define (common:version-changed?)
  (not (equal? (common:get-last-run-version)
               (common:version-signature))))


;; From 1.70 to 1.80, db's are compatible.

(define (common:api-changed?)
  (let* (
  (not (equal? (substring (->string megatest-version) 0 4)
               (substring (conc (common:get-last-run-version)) 0 4))))
    (megatest-major-version (substring (->string megatest-version) 0 4))
    (run-major-version (substring (conc (common:get-last-run-version)) 0 4))
   )
   (and (not (equal? megatest-major-version "1.80"))
     (not (equal? megatest-major-version megatest-run-version)))
  )
)

;;======================================================================
;; Move me elsewhere ...
;; RADT => Why do we meed the version check here, this is called only if version misma
;;
(define (common:cleanup-db dbstruct #!key (full #f))
  (apply db:multi-db-sync 
600
601
602
603
604
605
606
607

608
609
610
611
612
613
614
609
610
611
612
613
614
615

616
617
618
619
620
621
622
623







-
+







;; Force a megatest cleanup-db if version is changed and skip-version-check not specified
;; Do NOT check if not on homehost!
;;
(define (common:exit-on-version-changed)
  (if (common:on-homehost?)
      (if (common:api-changed?)
	  (let* ((mtconf (conc (get-environment-variable "MT_RUN_AREA_HOME") "/megatest.config"))
                 (dbfile  (conc (get-environment-variable "MT_RUN_AREA_HOME") "/megatest.db"))
                 (dbfile  (conc (get-environment-variable "MT_RUN_AREA_HOME") ".megatest/main.db"))
                 (read-only (not (file-write-access? dbfile)))
                 (dbstruct (db:setup #t))) ;; (db:setup-db *dbstruct-dbs* *toppath* #f))) ;;  #t)))
	    (debug:print 0 *default-log-port*
			 "WARNING: Version mismatch!\n"
			 "   expected: " (common:version-signature) "\n"
			 "   got:      " (common:get-last-run-version))
            (cond
624
625
626
627
628
629
630
631

632
633
634

635
636
637
638
639
640
641
633
634
635
636
637
638
639

640
641
642

643
644
645
646
647
648
649
650







-
+


-
+







                 (print-call-chain (current-error-port))
                 (exit 1))
               (common:cleanup-db dbstruct)))
             ((not (common:file-exists? mtconf))
              (debug:print 0 *default-log-port* "   megatest.config does not exist in this area.  Cannot proceed with megatest version migration.")
              (exit 1))
             ((not (common:file-exists? dbfile))
              (debug:print 0 *default-log-port* "   megatest.db does not exist in this area.  Cannot proceed with megatest version migration.")
              (debug:print 0 *default-log-port* "   .megatest/main.db does not exist in this area.  Cannot proceed with megatest version migration.")
              (exit 1))
             ((not (eq? (current-user-id)(file-owner mtconf)))
              (debug:print 0 *default-log-port* "   You do not own megatest.db in this area.  Cannot proceed with megatest version migration.")
              (debug:print 0 *default-log-port* "   You do not own .megatest/main.db in this area.  Cannot proceed with megatest version migration.")
              (exit 1))
             (read-only
              (debug:print 0 *default-log-port* "   You have read-only access to this area.  Cannot proceed with megatest version migration.")
              (exit 1))
             (else
              (debug:print 0 *default-log-port* " to switch versions you can run: \"megatest -cleanup-db\"")
              (exit 1)))))))