Re: Fwd: World's simplest Scheme interface to sqlite3
Lassi Kortela 02 Sep 2020 08:38 UTC
>>> -table-names and -column-names
>
> An even more mainstream (and arguably important) use for these is in
> automatic schema migration; if your application, upon opening a database
> file, checks to see what tables and columns exist, it can add any that
> are missing. This enables:
>
> 1) When creating a new file, the application will fill it with empty
> tables so that subsequent inserts will work.
>
> 2) When V2 of your app opens a file created with V1, it will upgrade the
> schema (in a way that, if your app is carefully written, will not
> prevent the file being opened by V1 again, too, but that's a separate
> issue!) so that V2 queries will work.
Is that technique really mainstream? It sounds kind of brittle. The
usual way to do schema migration is to store the version number of the
schema in a special table (this can be a running counter, a date and
time, or something fancier like a hash).
However, since both you and John came up with a realistic example, we
should probably add those procedures.