diff --git a/app/Jobs/ProcessStmtEntryDataJob.php b/app/Jobs/ProcessStmtEntryDataJob.php index 9970186..a9d5d63 100644 --- a/app/Jobs/ProcessStmtEntryDataJob.php +++ b/app/Jobs/ProcessStmtEntryDataJob.php @@ -191,12 +191,12 @@ { try { if (!empty($this->entryBatch)) { - // Bulk insert/update statement entries - StmtEntry::upsert( - $this->entryBatch, - ['stmt_entry_id'], // Unique key - array_diff((new StmtEntry())->getFillable(), ['stmt_entry_id']) // Update columns - ); + foreach ($this->entryBatch as $entry) { + StmtEntry::updateOrCreate( + ['stmt_entry_id' => $entry['stmt_entry_id']], // Find by this key + $entry // Update or create with these values + ); + } // Reset entry batch after processing $this->entryBatch = []; diff --git a/database/migrations/2025_05_29_123622_add_unique_constraint_to_stmt_entry_table.php b/database/migrations/2025_05_29_123622_add_unique_constraint_to_stmt_entry_table.php new file mode 100644 index 0000000..48ac884 --- /dev/null +++ b/database/migrations/2025_05_29_123622_add_unique_constraint_to_stmt_entry_table.php @@ -0,0 +1,28 @@ +