Skip to content

Commit

Permalink
Move expiration upgrade to schema v502.
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbirks committed Oct 24, 2024
1 parent df4af06 commit dff750a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions LiteCore/Storage/SQLiteDataFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ namespace litecore {
error::_throw(error::CantUpgradeDatabase);
}

(void)upgradeSchema(SchemaVersion::WithIndexesLastSeq, "Adding indexes.lastSeq column", [&] {
string sql;
if ( getSchema("indexes", "table", "indexes", sql) ) {
// Check if the table needs to be updated to add the 'lastSeq' column: (v3.2)
if ( sql.find("lastSeq") == string::npos ) { _exec("ALTER TABLE indexes ADD COLUMN lastSeq TEXT"); }
}
});

(void)upgradeSchema(SchemaVersion::WithExpirationColumn, "Adding `expiration` column", [&] {
// Add the 'expiration' column to every KeyStore:
for ( string& name : allKeyStoreNames() ) {
Expand All @@ -348,14 +356,6 @@ namespace litecore {
}
}
});

(void)upgradeSchema(SchemaVersion::WithIndexesLastSeq, "Adding indexes.lastSeq column", [&] {
string sql;
if ( getSchema("indexes", "table", "indexes", sql) ) {
// Check if the table needs to be updated to add the 'lastSeq' column: (v3.2)
if ( sql.find("lastSeq") == string::npos ) { _exec("ALTER TABLE indexes ADD COLUMN lastSeq TEXT"); }
}
});
});

// Configure number of extra threads to be used by SQLite:
Expand Down
4 changes: 2 additions & 2 deletions LiteCore/Storage/SQLiteDataFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ namespace litecore {

WithNewDocs = 400, // New document/revision storage (CBL 3.0)

WithExpirationColumn = 490, // Added 'expiration' column to KeyStore
WithDeletedTable = 500, // Added 'deleted' KeyStore for deleted docs (CBL 3.0?)
WithIndexesLastSeq = 501, // Added 'lastSeq' column to 'indexes' table (CBL 3.2)
WithExpirationColumn = 502, // Added 'expiration' column to KeyStore
MaxReadable = 599, // Cannot open versions newer than this

Current = WithDeletedTable
Current = WithExpirationColumn
};

void reopenSQLiteHandle();
Expand Down

0 comments on commit dff750a

Please sign in to comment.