Laravel迁移-表前缀问题 [英] Laravel Migrations - Table Prefix Issue

查看:572
本文介绍了Laravel迁移-表前缀问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm building a dummy site to test Laravel 3.x.

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

I'm creating my site migrations right now. Everything was doing just fine until the following error showed up:

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

问题是laravel突然开始为'laravel_migrations'表添加前缀(当该表只能与其他表一起使用时).

The issue is that laravel all of a sudden started to prefix the 'laravel_migrations' table (when it is supposed to do it only with the other ones).

我想知道我是在做错什么还是已知问题.

I wonder if I'm doing something wrong or if it is a known issue.

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

I'm trying to run the following migration (using the php artisan migrate application command):

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();
    });
}

任何帮助都会很棒.

  • 几分钟前,我注意到我的表根本没有前缀,即使在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:resetmigrate 我已经做到了,它的作品很完美

After setting this, migrate:reset and migrate it again I have done this way and its works perfect

这篇关于Laravel迁移-表前缀问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆