SliceTableFeedLog.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Console\Commands\Upgrade;
  3. use App\Models\Log\FeedLogModel;
  4. use Illuminate\Console\Command;
  5. use Illuminate\Support\Facades\Redis;
  6. class SliceTableFeedLog extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'upgrade:sliceTableFeedLog';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'feedLog表分表操作的升级脚本';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. FeedLogModel::where('id', '>', 0)->orderBy('id', 'asc')->each(function (/** @var FeedLogModel $item */ $item) {
  37. FeedLogModel::create([
  38. 'created_at' => $item->created_at,
  39. 'updated_at' => $item->updated_at,
  40. 'uid' => $item->uid,
  41. 'partner_id' => $item->partner_id,
  42. 'ismock' => $item->ismock
  43. ]);
  44. Redis::set("upgrade:sliceTableFeedLog", $item->id);
  45. });
  46. }
  47. }