laravel 5 如何创建枢轴 table
How is a pivot table created by laravel 5
在应用解决方案后,我遵循了 http://four.laravel.com/docs/eloquent#many-to-many and I found the same problem in How is a pivot table created by laravel 中的所有内容,我得到了迁移文件并进行了更改
public function up()
{
Schema::table('Card_User', function (Blueprint $table) {
$table->increments('id');
$table->integer('Card_id');
$table->integer('User_id');
$table->integer('additional_var');
});
}
但是当我尝试 php artisan migrate:refresh
我总是得到
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.Card_User' d
oesn't exist (SQL: alter table `Card_User` add `id` int unsigned not null auto
_increment primary key, add `Card_id` int not null, add `User_id` int not null
, add `additional_var` int not null)
[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'waawia.Card_User' d
oesn't exist
After folowwing some other webpages i tried to :
php artisan migrate:install
Delete all the database tables manually and refresh the migration
Restarted php artisan serve
and now it's closed
Some other things ...
But still have the same problem
如果您要创建 table,请更改
Schema::table('Card_User', function (Blueprint $table) {}
到
Schema::create('Card_User', function (Blueprint $table) {}
Schema::table()
用于更改现有的 table,而 Schema::create()
则按其含义执行。
在应用解决方案后,我遵循了 http://four.laravel.com/docs/eloquent#many-to-many and I found the same problem in How is a pivot table created by laravel 中的所有内容,我得到了迁移文件并进行了更改
public function up()
{
Schema::table('Card_User', function (Blueprint $table) {
$table->increments('id');
$table->integer('Card_id');
$table->integer('User_id');
$table->integer('additional_var');
});
}
但是当我尝试 php artisan migrate:refresh
我总是得到
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.Card_User' d
oesn't exist (SQL: alter table `Card_User` add `id` int unsigned not null auto
_increment primary key, add `Card_id` int not null, add `User_id` int not null
, add `additional_var` int not null)
[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'waawia.Card_User' d
oesn't exist
After folowwing some other webpages i tried to :
php artisan migrate:install
Delete all the database tables manually and refresh the migration
Restarted
php artisan serve
and now it's closedSome other things ...
But still have the same problem
如果您要创建 table,请更改
Schema::table('Card_User', function (Blueprint $table) {}
到
Schema::create('Card_User', function (Blueprint $table) {}
Schema::table()
用于更改现有的 table,而 Schema::create()
则按其含义执行。