通过Laravel迁移创建的表中列前面的空格

时间:2019-03-20 01:52:14

标签: mysql laravel-5 database-migration

有人通过Laravel迁移创建表时遇到像我这样的问题吗,还有多余的空间吗?

我会为这个迁移文件重新运行几次,但仍会创建额外的空间。

我的环境。

  • Laravel 5.6
  • PHP 7.2
  • MySQL 5.7.23

这是我的照片和迁移内容。

enter image description here

enter image description here

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();

它按预期工作。

如图所示:

enter image description here

仍然无法确定是引起问题的地方。

----- 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');
    }
}

1 个答案:

答案 0 :(得分:0)

尝试在终端中运行以下命令:

  1. composer dump-autoload
  2. php artisan config:cache
  3. php artisan migrate:fresh