在Lumen中执行迁移时没有设置表名

hen*_*ale 7 php laravel lumen

尝试在Lumen Framework中运行迁移时,我遇到此错误:

$ php artisan migrate:install

 [Illuminate\Database\QueryException]                                                                   
  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table ``  
   (`migration` varchar(255) not null, `batch` int not null) default character set utf8 collate utf8_unicode_ci)     

  [PDOException]                                                                   
  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' 
Run Code Online (Sandbox Code Playgroud)

现在我不知道发生了什么.

请注意,未创建的表是完全控制迁移的表.

hen*_*ale 27

我自己找到了解决方案!

只需在数据库配置数组中添加表的名称即可完成!

'migrations' => 'migrations',

  • 这对我有用,我在错误的地方添加了这个提示.它应该添加到连接图之外.有关详细信息,请访问https://github.com/laravel/lumen-framework/issues/248 (4认同)
  • 对我有用,多么愚蠢的事情。当您创建自定义 config/database.php 文件(在 Lumen 中)时,您必须将此解决方案添加到“连接”级别的主数组中。 (2认同)

小智 6

<?php
return [

    'default' => 'external',
    'migrations' => 'migrations',
    'connections' => [
        // your connections
    ],
];
Run Code Online (Sandbox Code Playgroud)