Checking a Database with verify
kent verify compares a database's structure against the schema this build
of Cordelia would create, and reports what differs.
It is read-only, and it is the diagnostic command: where the others refuse a database they cannot read, this one opens it anyway and tells you why.
Synopsis
kent verify <dbfilename>
A database that matches
$ kent verify mydata.sqlite
Database: mydata.sqlite
No differences: every table this database has matches the schema this build creates.
$ echo $?
0
A database that does not
Every difference is one line, and the count is repeated at the end so a long report is still readable. This is a database written under schema 1, checked by a build that creates schema 2:
$ kent verify old.sqlite
Database: old.sqlite
difference: user_version: this build writes 2, the database reports 1
difference: Monitoring.intensity: the database says INTEGER, this build says REAL
difference: Monitoring.ascent: the database says INTEGER, this build says REAL
difference: Monitoring.descent: the database says INTEGER, this build says REAL
4 differences from the schema this build creates.
$ echo $?
1
A column the database has and Cordelia does not create is reported the same way, which is what you see if something outside Cordelia has written to the file:
$ kent verify drifted.sqlite
Database: drifted.sqlite
difference: Session.my_extra_column: the database has this column, this build does not create it
1 difference from the schema this build creates.
$ echo $?
1
It reads a database the others refuse
info,
details,
files,
activities and
sports all refuse a database whose
user_version is older than this build expects. verify
does not, deliberately: a wrong version is the case it exists to diagnose, so
refusing to open the file would make it useless exactly when it is needed.
What it does not check
It compares structure, not content: tables, columns and their declared types, plus the
schema version. It does not validate the data in the rows, and it does not check that
SQLite's own file format is intact. For the latter, SQLite's
PRAGMA integrity_check is the right tool.
It also reports only differences in tables the database has. A table Cordelia defines and this database never created is not a finding, because a database materializes only what its imported data needed. That is normal, and the published sport databases are all like that: 14 tables out of the 128 the schema defines.
Exit codes
0 when nothing differs, 1 when anything does. That makes it
usable as a test in a script, which is the reason it prints a count as well as the lines.