mysql - 从 Laravel 迁移创建时,表中列前的空格
问题描述
有没有人遇到像我这样的问题,当我通过 Laravel 迁移创建表时有多余的空间?
而且我为这个迁移文件重新运行了几次,但仍然创建了额外的空间。
我的环境。
- 拉拉维尔 5.6
- PHP 7.2
- MySQL 5.7.23
下面是我的图片和迁移内容。
Schema::create('plugin_packages', function (Blueprint $table) {
$table->char('id', 36)->primary();
$table->char('plugin_id', 36)->nullable();
$table->char('plugin_package_device_model_id', 36)->nullable();
$table->char('plugin_package_os_version_id', 36)->nullable();
$table->string('version_number');
$table->string('file');
$table->timestamps();
$table->softDeletes();
$table->foreign('plugin_id')->references('id')->on('plugins')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('plugin_package_device_model_id', 'ppdm_id_foreign')->references('id')->on('plugin_package_device_models')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('plugin_package_os_version_id', 'ppov_id_foreign')->references('id')->on('plugin_package_os_versions')->onUpdate('cascade')->onDelete('cascade');
});
谢谢你。
------2019.03.21更新-----
走到柱子\u0096\u0096
前面plugin_package_os_version_id
。
[{"id":"14f0c766-341c-4262-9a33-0b8fc3063cad","plugin_id":"b3f09e90-cd8b-4e18-9b5e-c9176a5ea898","plugin_package_device_model_id":"a7a630e3-3fac-40c3-b3ed-61d54eb91d6f","\u0096\u0096plugin_package_os_version_id":"623eaf52-09dd-4837-aa9e-79e4f930d654","version_number":"1.0.1","file":"uploads\/application-x-dosexec\/2019-03-12\/FECEdgeServiceSETUP_3484fe18556c19479f8b6caf5c60ec98.exe","created_at":"2019-03-21 14:12:43","updated_at":"2019-03-21 14:12:43","deleted_at":null}]
------2019.03.21 更新 2--------
如果我从
$table->char('plugin_package_os_version_id', 36)->nullable();
至
$table->char('ppov_id', 36)->nullable();
它按预期工作。
如图所示:
仍然无法确定导致问题的位置。
-----2019.03.21更新3--------
迁移文件的全部内容
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePluginPackagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('plugin_packages', function (Blueprint $table) {
$table->char('id', 36)->primary();
$table->char('plugin_id', 36)->nullable();
$table->char('plugin_package_device_model_id', 36)->nullable();
$table->char('plugin_package_os_version_id', 36)->nullable();
$table->string('version_number');
$table->string('file');
$table->timestamps();
$table->softDeletes();
$table->foreign('plugin_id')->references('id')->on('plugins')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('plugin_package_device_model_id', 'ppdm_id_foreign')->references('id')->on('plugin_package_device_models')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('plugin_package_os_version_id', 'ppov_id_foreign')->references('id')->on('plugin_package_os_versions')->onUpdate('cascade')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('plugin_packages');
}
}
解决方案
尝试在终端中运行以下命令:
composer dump-autoload
php artisan config:cache
php artisan migrate:fresh
推荐阅读
- dart - 飞镖中的最大/最小 int/double 值是否有常数?
- image-processing - Keras 和 Tensorflow GPU 在大图像数据上内存不足
- php - WordPress - 如何获取帖子内容和标题
- java - Java Freemarker 模板引擎只能访问自定义注释方法?
- algorithm - ADT(抽象数据类型)和容器有什么区别?
- placeholder - 仅将占位符中的星号更改为红色
- php - 如何将动态值从一个 php 页面“转移”到另一个 php 页面?
- r - barp() 的 Y 轴问题
- python - Python中的浅拷贝而不是新对象
- php - php 未定义的索引 id 但 if(isset($_POST['id'])) 语句工作正常