Laravel工匠没有创建所有列

时间:2014-11-08 09:04:54

标签: mysql laravel-4 artisan octobercms

当OctoberCMS创建此表时,它只有id列。

我无法弄清楚原因。

以下是我的updates / createTable.php文件中的类。

class CreateCellphoneTable extends Migration
{

  public function up()
  {
    Schema::create('iaff106_cell_phones', function($table)
    {
        $table->engine = 'InnoDB';
        $table->increments('id');
        $table->integer('user_id')->unsigned()->nullable()->index();
        $table->string('label')->nullable();
        $table->string('phone')->index();
        $table->integer('provider_id')->nullable();
        $table->boolean('cantxt')->default(true);
        $table->boolean('published')->default(false);
        $table->timestamps();
    });
  }
}

我正在执行这样的工匠:

php artisan plugin:refresh IAFF106.CellPhone

3 个答案:

答案 0 :(得分:0)

我已经测试了您创建所有字段的代码

您是否导入了所有需要的类

这是我的createTable.php代码

<?php namespace IAFF106\CellPhone\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class CreateCellphoneTable extends Migration
{

    public function up()
    {
        Schema::create('iaff106_cell_phones', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->integer('user_id')->unsigned()->nullable()->index();
            $table->string('label')->nullable();
            $table->string('phone')->index();
            $table->integer('provider_id')->nullable();
            $table->boolean('cantxt')->default(true);
            $table->boolean('published')->default(false);
            $table->timestamps();
        });
    }
}

和version.yaml中的代码是

1.0.1:
      - First version of CellPhone
      - createTable.php

enter image description here

我希望你在version.yaml文件中指定了createTable.php

答案 1 :(得分:0)

事实证明,Artisan并不是很好地报告像拼写错误的PHP文件这样的问题。

我在我的version.yaml文件中拼错了createTable.php文件。 Artisan没有做任何事情,即使它没有抱怨,一切看起来还不错。

anand patel的回答和我回来的新面貌的结合帮助我找到了这个。

答案 2 :(得分:0)

当您在up()函数中有重复的列时,有时会发生这种情况,请仔细检查您的列以确保。