Skip to content

Commit

Permalink
#452 - updated migration command (#460)
Browse files Browse the repository at this point in the history
- refactor: updated migrate command
  • Loading branch information
kamilpiech97 authored Jul 5, 2024
1 parent d40b4b2 commit c168267
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/Console/Commands/MigrateProfileDataIntoUserHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function handle(): void
private function moveMedicalDataToHistory(User $user): void
{
if ($user->profile->last_medical_exam_date && $user->profile->next_medical_exam_date) {
$user->histories()->create([
$user->histories()->firstOrCreate([
"from" => $user->profile->last_medical_exam_date,
"to" => $user->profile->next_medical_exam_date,
"type" => UserHistoryType::MedicalExam,
Expand All @@ -40,7 +40,7 @@ private function moveMedicalDataToHistory(User $user): void
private function moveOhsDataToHistory(User $user): void
{
if ($user->profile->last_ohs_training_date && $user->profile->next_ohs_training_date) {
$user->histories()->create([
$user->histories()->firstOrCreate([
"from" => $user->profile->last_ohs_training_date,
"to" => $user->profile->next_ohs_training_date,
"type" => UserHistoryType::OhsTraining,
Expand All @@ -51,7 +51,7 @@ private function moveOhsDataToHistory(User $user): void
private function moveEmploymentDataToHistory(User $user): void
{
if ($user->profile->employment_date) {
$user->histories()->create([
$user->histories()->firstOrCreate([
"from" => $user->profile->employment_date,
"to" => null,
"type" => UserHistoryType::Employment,
Expand Down

0 comments on commit c168267

Please sign in to comment.