2022_09_01_043002_generate_missing_profile_webfinger.php 848 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. use App\Profile;
  6. class GenerateMissingProfileWebfinger extends Migration
  7. {
  8. /**
  9. * Run the migrations.
  10. *
  11. * @return void
  12. */
  13. public function up()
  14. {
  15. Profile::whereNotNull('domain')
  16. ->whereNull('webfinger')
  17. ->chunk(200, function($profiles) {
  18. foreach($profiles as $profile) {
  19. if(substr($profile->username, 0, 1) === "@") {
  20. $profile->webfinger = $profile->username;
  21. $profile->save();
  22. }
  23. }
  24. });
  25. }
  26. /**
  27. * Reverse the migrations.
  28. *
  29. * @return void
  30. */
  31. public function down()
  32. {
  33. //
  34. }
  35. }