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()
{
DB::table('lexical_entries')->truncate();
$this->info("Preparing to import lexical entries.");
DB::transaction(function() {
DB::table('lexical_entries')->truncate();
$importHandler = new LexiconEntryImportHandler();
$importHandler->run();
$importHandler = new LexiconEntryImportHandler();
$this->info("Import in progress.");
$importHandler->run();
});
$this->info("Import Complete.");
}
}

View File

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