Switch to WAL after cipher migration
This commit is contained in:
parent
4a6132933c
commit
9693700dd2
1 changed files with 4 additions and 1 deletions
|
@ -329,7 +329,8 @@ function setUserVersion(db: Database, version: number): void {
|
||||||
function keyDatabase(db: Database, key: string): void {
|
function keyDatabase(db: Database, key: string): void {
|
||||||
// https://www.zetetic.net/sqlcipher/sqlcipher-api/#key
|
// https://www.zetetic.net/sqlcipher/sqlcipher-api/#key
|
||||||
db.pragma(`key = "x'${key}'"`);
|
db.pragma(`key = "x'${key}'"`);
|
||||||
|
}
|
||||||
|
function switchToWAL(db: Database): void {
|
||||||
// https://sqlite.org/wal.html
|
// https://sqlite.org/wal.html
|
||||||
db.pragma('journal_mode = WAL');
|
db.pragma('journal_mode = WAL');
|
||||||
db.pragma('synchronous = NORMAL');
|
db.pragma('synchronous = NORMAL');
|
||||||
|
@ -384,6 +385,7 @@ function openAndMigrateDatabase(filePath: string, key: string) {
|
||||||
try {
|
try {
|
||||||
db = new SQL(filePath);
|
db = new SQL(filePath);
|
||||||
keyDatabase(db, key);
|
keyDatabase(db, key);
|
||||||
|
switchToWAL(db);
|
||||||
migrateSchemaVersion(db);
|
migrateSchemaVersion(db);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
|
@ -410,6 +412,7 @@ function openAndMigrateDatabase(filePath: string, key: string) {
|
||||||
keyDatabase(db, key);
|
keyDatabase(db, key);
|
||||||
|
|
||||||
db.pragma('cipher_migrate');
|
db.pragma('cipher_migrate');
|
||||||
|
switchToWAL(db);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue