From 87cff47c03d0855f3589422aa415d165ab354f14 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 14 Jan 2023 21:26:41 -0700 Subject: [PATCH] Add migration --- ..._add_missing_profile_id_to_users_table.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 database/migrations/2023_01_15_041933_add_missing_profile_id_to_users_table.php diff --git a/database/migrations/2023_01_15_041933_add_missing_profile_id_to_users_table.php b/database/migrations/2023_01_15_041933_add_missing_profile_id_to_users_table.php new file mode 100644 index 00000000..9ea582e4 --- /dev/null +++ b/database/migrations/2023_01_15_041933_add_missing_profile_id_to_users_table.php @@ -0,0 +1,39 @@ +chunk(20, function($users) { + foreach($users as $user) { + $profile = Profile::whereUsername($user->username)->first(); + if($profile) { + $user->profile_id = $profile->id; + $user->save(); + } + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +};