在Laravel中使用迁移重命名表

A.J*_*A.J 3 php sql migration laravel

我正在运行迁移以重命名表,但我得到一个奇怪的错误.

public function up()
{   
    Schema::rename($accounts, $feeds);
}   

public function down()
{   
    Schema::rename($feeds, $accounts);
}   
Run Code Online (Sandbox Code Playgroud)

错误:

Undefined variable: accounts

表绝对存在.知道可能是什么问题吗?

Ale*_*nin 8

你应该使用字符串而不是变量:

public function up()
{   
    Schema::rename('accounts', 'feeds');
}   

public function down()
{   
    Schema::rename('feeds', 'accounts');
}   
Run Code Online (Sandbox Code Playgroud)

  • 傻我.将在9分钟内接受.谢谢! (2认同)