Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added explicit primary keys to all entity tables
* Without an explicit primary key constraint, SQLite may reassign `rowid` columns when records are deleted and a subsequent `VACUUM` command is issued. This would break referential integrity in the database. * Prior to this change it worked because the application never deletes records, so `rowid` values never changed after transactions have been committed. If, however, records were deleted manually, the database may become unusable after `VACUUM` runs. * This change instructs SQLite to respect `rowid` values because now they are aliased by newly added primary key columns. * All current SQL will still work because `rowid` may be referenced either as such or as the new `id` column. For new records that are being inserted, the new `id` column should not be listed in the column list of `INSERT INTO` statements and it will be populated using the usual `rowid` rules. * There is no upgrade SQL provided because SQLite does not allow changing primary keys on existing tables without copying entire tables via temporary tables. The existing schema will keep working as long as there are no records deleted from any of the entity tables.
- Loading branch information