diff --git a/database/migrations/2022_11_19_220435_add_hour_to_hosts.php b/database/migrations/2022_11_19_220435_add_hour_to_hosts.php new file mode 100644 index 0000000..35e2e81 --- /dev/null +++ b/database/migrations/2022_11_19_220435_add_hour_to_hosts.php @@ -0,0 +1,43 @@ +tinyInteger('hour')->index()->nullable()->after('status'); + }); + + Host::chunk(100, function ($hosts) { + foreach ($hosts as $host) { + $host->hour = $host->created_at->hour; + $host->save(); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('hosts', function (Blueprint $table) { + // + + $table->dropColumn('hour'); + }); + } +};