diff --git a/database/migrations/2022_11_19_220435_add_hour_to_hosts.php b/database/migrations/2022_11_19_220435_add_hour_at_to_hosts.php similarity index 72% rename from database/migrations/2022_11_19_220435_add_hour_to_hosts.php rename to database/migrations/2022_11_19_220435_add_hour_at_to_hosts.php index 35e2e81..98789ca 100644 --- a/database/migrations/2022_11_19_220435_add_hour_to_hosts.php +++ b/database/migrations/2022_11_19_220435_add_hour_at_to_hosts.php @@ -16,15 +16,17 @@ public function up() Schema::table('hosts', function (Blueprint $table) { // - $table->tinyInteger('hour')->index()->nullable()->after('status'); + $table->tinyInteger('hour_at')->index()->nullable()->after('status'); }); + echo PHP_EOL . '将开始刷新主机的小时数...'; Host::chunk(100, function ($hosts) { foreach ($hosts as $host) { - $host->hour = $host->created_at->hour; + $host->hour_at = $host->created_at->hour; $host->save(); } }); + echo ' 完成!' . PHP_EOL; } /** @@ -37,7 +39,7 @@ public function down() Schema::table('hosts', function (Blueprint $table) { // - $table->dropColumn('hour'); + $table->dropColumn('hour_at'); }); } };