Skip to content

Commit

Permalink
Check expiration column exists before adding.
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbirks committed Oct 24, 2024
1 parent 39444b2 commit df4af06
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LiteCore/Storage/SQLiteDataFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ namespace litecore {
// Add the 'expiration' column to every KeyStore:
for ( string& name : allKeyStoreNames() ) {
if ( name.find("::") == string::npos ) {
string sql;
// We need to check for existence of the expiration column first.
// Do not add it if it already exists in the table.
if ( getSchema("kv_" + name, "table", "kv_" + name, sql)
&& sql.find("expiration") != string::npos )
continue;
// Only update data tables, not FTS index tables
_exec(format(
"ALTER TABLE \"kv_%s\" ADD COLUMN expiration INTEGER; "
Expand Down

0 comments on commit df4af06

Please sign in to comment.