【问题标题】:Rename table using migration in Laravel在 Laravel 中使用迁移重命名表
【发布时间】:2018-07-18 04:38:46
【问题描述】:

我正在运行迁移以重命名表,但出现奇怪的错误。

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

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

错误

Undefined variable: accounts

表肯定存在。知道可能是什么问题吗?

【问题讨论】:

    标签: php sql laravel migration


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-11-25
      • 2018-12-10
      • 2020-06-22
      • 2014-12-18
      • 2017-06-10
      • 2019-08-24
      • 2015-07-05
      • 2016-10-11
      • 1970-01-01
      相关资源
      最近更新 更多