1
我不知道是否有一個「SQL緩存」或東西在Laravel 5.4LARAVEL 5.4 SQL「列未找到」,而播種
我有這個SQL問題,同時運行工匠分貝默認啓用:種子:
SQLSTATE[42703]: Undefined column: 7 ERROR: column « category »
of relation « projects » doesn't exists
LINE 1: insert into "projects" ("category", "user_id","updated_at",...
列類別確實存在過,但我給它改名到CATEGORY_ID
create_project_table遷移:
class CreateProjectsTable extends Migration
{
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->increments('id');
$table->integer('category_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->string('title')->unique();
$table->text('content');
$table->boolean('published')->default('false');
$table->integer('views_count')->nullable();
$table->integer('likes_count')->nullable();
$table->timestamps();
$table->foreign('category_id')
->references('id')
->on('project_categories')
->onDelete('restrict');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
用戶表播種機:
class UsersTableSeeder extends Seeder
{
public function run()
{
$users = factory(App\User::class, 50)
->create()
->each(function ($u) {
$u->projects()->save(factory(App\Project::class)->make());
});
}
}
ProjectFactory:
$factory->define(App\Project::class, function (Faker\Generator $faker) {
return [
'title' => $faker->text($maxNbChars = 50),
'content' => $faker->text($maxNbChars = 300),
'category_id' => $faker->numberBetween(1,50),
'published' => $faker->boolean($chanceOfGettingTrue = 50),
'user_id' => $faker->numberBetween(1,50),
'views_count' => $faker->numberBetween(1,200),
'likes_count' => $faker->numberBetween(1,200)
];
});
PS: 我已經跑了:
PHP工匠遷移:刷新
PHP工匠緩存:明確
更新
我可以創建一個項目在廷克沒有這個錯誤
您是否在任何地方使用Cache :: remember()函數? –
humm不,我沒有使用它 –