SQLSTATE[42S02] artisan tinker 问题
SQLSTATE[42S02] Problem with artisan tinker
我对 artisan tinker 有疑问
问题:
Illuminate\Database\QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.projects' doesn't exist (SQL: insert into `projects` (`title`, `description`, `updated_at`, `created_at`) values (My first Project, bla bla, 2020-12-18 14:21:42, 2020-12-18 14:21:42))'
我的迁移文件:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class BusinessTable extends Migration
{
/**
* Выполнение миграций.
*
* @return void
*/
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('mail');
$table->string('web-site');
$table->timestamps();
});
}
/**
* Отмена миграций.
*
* @return void
*/
public function down()
{
Schema::drop('business');
}
}
您的问题与 Business Migration 无关。
您的业务迁移应该如何:
Schema::create('business',
不是flights
。
关于项目 Table.
您必须创建项目迁移:
php artisan make:migration projects_table
并填充必填字段:
class ProjectsTable extends Migration
{
/**
* Выполнение миграций.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('description');
$table->timestamps();
});
}
/**
* Отмена миграций.
*
* @return void
*/
public function down()
{
Schema::drop('projects');
}
}
我对 artisan tinker 有疑问 问题:
Illuminate\Database\QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.projects' doesn't exist (SQL: insert into `projects` (`title`, `description`, `updated_at`, `created_at`) values (My first Project, bla bla, 2020-12-18 14:21:42, 2020-12-18 14:21:42))'
我的迁移文件:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class BusinessTable extends Migration
{
/**
* Выполнение миграций.
*
* @return void
*/
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('mail');
$table->string('web-site');
$table->timestamps();
});
}
/**
* Отмена миграций.
*
* @return void
*/
public function down()
{
Schema::drop('business');
}
}
您的问题与 Business Migration 无关。
您的业务迁移应该如何:
Schema::create('business',
不是flights
。
关于项目 Table.
您必须创建项目迁移:
php artisan make:migration projects_table
并填充必填字段:
class ProjectsTable extends Migration
{
/**
* Выполнение миграций.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('description');
$table->timestamps();
});
}
/**
* Отмена миграций.
*
* @return void
*/
public function down()
{
Schema::drop('projects');
}
}