add times field to magic table

This commit is contained in:
xiaomlove
2022-05-03 15:03:28 +08:00
parent 17339bda67
commit 71d10de4c2

View File

@@ -0,0 +1,37 @@
<?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()
{
Schema::table('magic', function (Blueprint $table) {
if (!Schema::hasColumn('magic', 'created_at')) {
$table->dateTime('created_at')->useCurrent();
}
if (!Schema::hasColumn('magic', 'updated_at')) {
$table->dateTime('updated_at')->useCurrent()->useCurrentOnUpdate();
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('magic', function (Blueprint $table) {
$table->dropColumn(['created_at', 'updated_at']);
});
}
};