lib/cli/create_db: make WAL mode optional
This commit is contained in:
@@ -13,6 +13,7 @@ Future<Database> openLocalDb({
|
||||
String? jadbPath,
|
||||
bool readWrite = false,
|
||||
bool assertTablesExist = true,
|
||||
bool walMode = false,
|
||||
}) async {
|
||||
libsqlitePath ??= Platform.environment['LIBSQLITE_PATH'];
|
||||
jadbPath ??= Platform.environment['JADB_PATH'];
|
||||
@@ -42,7 +43,9 @@ Future<Database> openLocalDb({
|
||||
jadbPath,
|
||||
options: OpenDatabaseOptions(
|
||||
onConfigure: (db) async {
|
||||
await db.execute("PRAGMA journal_mode = WAL");
|
||||
if (walMode) {
|
||||
await db.execute("PRAGMA journal_mode = WAL");
|
||||
}
|
||||
await db.execute("PRAGMA foreign_keys = ON");
|
||||
},
|
||||
readOnly: !readWrite,
|
||||
|
||||
@@ -12,6 +12,16 @@ class CreateDb extends Command {
|
||||
|
||||
CreateDb() {
|
||||
addLibsqliteArg(argParser);
|
||||
argParser.addFlag(
|
||||
'wal',
|
||||
help:
|
||||
'''Whether to use Write-Ahead Logging (WAL) mode.
|
||||
|
||||
This is recommended for better performance, but may not be used with
|
||||
the readonly NixOS store.
|
||||
''',
|
||||
defaultsTo: false,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> run() async {
|
||||
@@ -22,6 +32,7 @@ class CreateDb extends Command {
|
||||
|
||||
final db = await openLocalDb(
|
||||
libsqlitePath: argResults!.option('libsqlite')!,
|
||||
walMode: argResults!.flag('wal'),
|
||||
readWrite: true,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user