增加 时间戳

This commit is contained in:
iVampireSP.com 2023-01-20 15:34:48 +08:00
parent e57a03824b
commit 60b3593a8f
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('modules', function (Blueprint $table) {
$table->timestamps();
});
// 刷新时间戳
DB::table('modules')->update([
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('modules', function (Blueprint $table) {
$table->dropColumn('created_at');
$table->dropColumn('updated_at');
});
}
};