【发布时间】:2018-12-10 08:28:44
【问题描述】:
我使用 laravel 5.6
我想把author_ID改成user_id
我有如下所述的列:
class CreatePostsTable extends Migration{
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->bigInteger('author_ID');
$table->text('title');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('posts');
}
}
我使用下面的链接来更改我的列名:
How can I rename a column in laravel using migration?
然后创建打击迁移:
php artisan make:migration rename_author_id_in_post_table
重命名迁移文件:
class UpdateUsernameInPostTable extends Migration{
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->renameColumn('author_ID', 'user_id');
});
}
public function down()
{
Schema::create('posts', function (Blueprint $table) {
$table->renameColumn('user_id', 'author_ID');
});
}
}
但是使用运行命令:php artisan migrate 我有以下错误:
Symfony\Component\Debug\Exception\FatalThrowableError :
Class 'RenameAuthorIdInPostTable' not found
【问题讨论】: