On 2/16/16, Roger Binns <rogerb at rogerbinns.com> wrote: > > The way I (and many others) do it is to use the user_version. It is > an integer that starts out as zero, and can be read or written with > pragma user_version. Startup code then looks like this: > > if user_version()==0 { > BEGIN; > CREATE TABLE ....; > CREATE INDEX ....; > pragma user_version=1; > COMMIT; > }
Another approach is to use the sqlite3_table_column_metadata() interface to check for the existence of various tables and columns, and then run whatever CREATE TABLE and ALTER TABLE ADD COLUMN commands are necessary based on those findings. Whichever works best for you.... -- D. Richard Hipp drh at sqlite.org