Wrap the import processed with a transaction

This commit is contained in:
Leonard Smith 2021-05-06 12:08:41 -05:00
parent b8e68aec47
commit 82dcef8879
2 changed files with 19 additions and 12 deletions

View File

@ -39,9 +39,14 @@ class ImportLexicalEntries extends Command
*/
public function handle()
{
$this->info("Preparing to import lexical entries.");
DB::transaction(function() {
DB::table('lexical_entries')->truncate();
$importHandler = new LexiconEntryImportHandler();
$this->info("Import in progress.");
$importHandler->run();
});
$this->info("Import Complete.");
}
}

View File

@ -40,6 +40,7 @@ class ImportUlbXmlData extends Command
public function handle()
{
$this->info('Clearing out existing NT data...');
DB::transaction(function() {
DB::statement("SET FOREIGN_KEY_CHECKS=0");
DB::table('verses')->truncate();
DB::table('chapters')->truncate();
@ -50,5 +51,6 @@ class ImportUlbXmlData extends Command
$this->info('Importing fresh NT data...');
$importHandler = new UlbXmlImportHandler($this->output);
$importHandler->run();
});
}
}