diff --git a/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php b/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php index d586733..523c644 100644 --- a/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php +++ b/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php @@ -29,11 +29,15 @@ public function up(): void $table->timestamp('expired_at')->nullable()->after('last_paid_at'); }); + $hosts = Host::all(); + $count = $hosts->count(); // 为已有的主机设置默认值 - Host::all()->each(function (Host $host) { + Host::all()->each(function (Host $host) use (&$count) { + echo "Migrating {$host->id} ({$host->name})... {$count} left".PHP_EOL; + $host->day_at = $host->created_at->day; - $host->save(); + $host->saveQuietly(); }); }