【问题标题】:Laravel Eloquent: after() not adding column after a certain columnLaravel Eloquent:after()不在某列之后添加列
【发布时间】:2015-09-05 11:17:10
【问题描述】:

以下代码在最后而不是在特定列之后生成列。我在 Laravel 5.1

public function up()
    {
        Schema::table('project', function (Blueprint $table) {
            $table->enum('is_it',['yes','no'])->after('goals')->nullable();
        });
    }

我使用的是 PostgreSQL 9.4

【问题讨论】:

  • 这只适用于MySQL,你用的是MySQL吗?
  • 应该提到;没有postgresql

标签: php eloquent laravel-5.1


【解决方案1】:

当您使用 PostgreSQL 时,这是不可能的。此功能仅 MySQL 支持。

Column Modifiers Documentation 中,after 方法仅针对 MySQL 突出显示,您还可以在此处查看有关它的讨论:#14298

我希望这能澄清你的疑问,问候!

【讨论】:

    【解决方案2】:

    正如其他人所说,它不适用于 Postgresql,但这个问题在使用 MySQL 的 Laravel 8 中也存在。

    这是关于如何链接它们,这在 Laravel 8 上不起作用:

    $table->foreignIdFor(\App\Center::class)->references('id')->on('centers')->after('id');

    但这会:

    $table->foreignIdFor(\App\Center::class)->after('id')->references('id')->on('centers');.

    【讨论】:

      猜你喜欢
      • 2016-09-09
      • 2015-08-08
      • 2018-05-01
      • 2019-03-08
      • 1970-01-01
      • 1970-01-01
      • 2019-11-09
      • 2020-03-08
      • 1970-01-01
      相关资源
      最近更新 更多