我的帖子迁移是:
includes(:photo, :video).where('photos.is_processing IS NULL').rank(:position_in_gallery)
和频道:
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('channel_id');
$table->foreign('channel_id')->references('id')->on('channels');
$table->string('title');
$table->text('content');
$table->string('status')->default('published');
$table->string('type');
$table->string('published_at');
$table->timestamps();
});
现在,当我执行 Schema::create('channels', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description');
$table->string('channel_id');
$table->timestamps();
});
时,出现以下错误消息:
php artisan migrate
我正在使用Laravel 5.3,那就是我在我的本地计算机上使用MySQL就可以完美地运行迁移。但是当我在服务器上上传我的Laravel项目并在服务器上使用MariaDB时。我看到了错误信息。
答案 0 :(得分:2)
在posts
表格迁移中更改此内容:
$table->string('channel_id');
对此:
$table->integer('channel_id')->unsigned();
另外,请确保在channels
表迁移之前运行posts
表迁移。