增加 时间戳
This commit is contained in:
parent
e57a03824b
commit
60b3593a8f
@ -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');
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user