|
|
|
@@ -0,0 +1,47 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
use App\Util\MigrationHelper; |
|
|
|
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() |
|
|
|
{ |
|
|
|
$tables = Schema::getAllTables(); |
|
|
|
|
|
|
|
foreach ($tables as $table) { |
|
|
|
|
|
|
|
$tableName = $table->tablename; |
|
|
|
if (!Schema::hasColumn($tableName, "created_by") || !Schema::hasColumn($tableName, "updated_by")) continue; |
|
|
|
|
|
|
|
$type = Schema::getColumnType($tableName, "created_by"); |
|
|
|
|
|
|
|
if (!in_array($type, ['uuid', 'guid'])) { |
|
|
|
Schema::table($tableName, function (Blueprint $table) { |
|
|
|
$table->dropColumn("created_by"); |
|
|
|
$table->dropColumn("updated_by"); |
|
|
|
}); |
|
|
|
Schema::table($tableName, function (Blueprint $table) { |
|
|
|
$table->uuid("created_by")->nullable()->comment("作成者ID");; |
|
|
|
$table->uuid("updated_by")->nullable()->comment("更新者ID");; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Reverse the migrations. |
|
|
|
* |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
public function down() |
|
|
|
{ |
|
|
|
} |
|
|
|
}; |