我是laravel.I的新手。当我想使用不同的迁移创建第二个"timelog“时,我使用migration.But创建了表"users”,它给出了错误消息'table not found‘。然后我也删除了所有的迁移表和数据库表。我再次尝试使用migration.But创建表"users“,结果在终端中给出了错误信息。错误消息如下:
照明\数据库\QueryException
SQLSTATE42S02:找不到基表或视图: 1146表'hrm.users‘不存在(SQL: alter table users
add id
int U
无符号not null auto_increment主键,添加username
varchar(255) not null,添加email
varchar(255) not null,添加c
ontactnumber
varchar(255) not null,add password
varchar(255) not null,add created_at
timestamp default 0 not null,ad
D updated_at
时间戳默认值0非null)
PDOException
SQLSTATE42S02:找不到基表或视图: 1146表'hrm.users‘不存在
我该如何解决这个问题呢?
发布于 2014-11-17 08:26:53
检查你的app/database/migrations文件夹,如果你迁移,Laravel会创建所有不在迁移表中的表。
sql查询表明您正在尝试更改-而不是创建-一个表,因此请查看迁移类,并确保它们如下所示:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSomething extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('something', function($table) {
$table->increments('id');
...
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//drop the table
}
}
https://stackoverflow.com/questions/26968161
复制