php - Laravel 迁移 - 表前缀问题

标签 php migration laravel laravel-3

我正在构建一个虚拟站点来测试 Laravel 3.x。

我现在正在创建我的网站迁移。一切都很好,直到出现以下错误:

SQLSTATE[42s02]: Base table or view not found: 1146 Table 'databasenamehere.prefix_laravel_migrations' doesn't exist

问题是 laravel 突然开始为 'laravel_migrations' 表添加前缀(当它应该只与其他表一起做时)。

我想知道是我做错了什么还是已知问题。

我正在尝试运行以下迁移(使用 php artisan migrate application 命令):

public function up()
{
    Schema::create('siteinfo', function ($table) 
    {
        $table->engine = 'InnoDB';
        $table->string('name');
        $table->string('title')->nullable();
        $table->string('corp_name')->nullable();
        $table->string('corp_addr')->nullable();
        $table->string('corp_phone')->nullable();
        $table->string('corp_city')->nullable();
        $table->string('corp_state')->nullable();
        $table->string('corp_email')->nullable();
        $table->string('main_url')->nullable();
        $table->timestamps();
    });
}

任何帮助都会很棒。

编辑 1:

  • 几分钟前我注意到我的表根本没有前缀,即使在 config/database.php 文件中正确设置了“前缀”配置也是如此。
  • 如果我删除前缀,一切正常。我知道我可以在每次运行的迁移中手动设置前缀,但是...

最佳答案

application->config->database.php中设置prefix如下

'mysql' => array(
'driver'   => 'mysql',
'host'     => 'localhost',
'database' => 'foodb',
'username' => 'root',
'password' => '',
'charset'  => 'utf8',
'prefix'   => 'ula_',       <-- this is where you need to set the table prefix
),

设置好后,migrate:reset 并再次migrate 我已经这样做了,而且效果很好

关于php - Laravel 迁移 - 表前缀问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15885681/

相关文章:

php - 使用 php 的客户端到客户端套接字

php - 在我自己的脚本中使用 jimport

ios - 如何迁移已使用 NSKeyedArchiver 持久化的对象?

php - 是否可以使用 dompdf 导出 Google 图表?

mysql - 使用 Postgres 在 Laravel 5.3 中更新区分大小写的数据库字段

javascript - 如何使我的横幅定期刷新到另一个随机横幅?

php - 搜索php后对数组值进行排序

Python:if-endif-statement 在哪里结束?

ios - iOS 13 Core Data 持久化存储迁移过程中出现错误

javascript - 使用 jsonParse 解析数据