【问题标题】:SQLSTATE[42S02] Problem with artisan tinkerSQLSTATE [42S02] 工匠修补程序的问题
【发布时间】:2021-03-29 05:26:08
【问题描述】:

我对工匠修补匠有疑问 问题:

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

【问题讨论】:

  • .env 文件中的数据集是否正确?您是否使用 php artisan migrate 运行迁移?

标签: laravel laravel-artisan migrate artisan-migrate tinker


【解决方案1】:

您的问题与商业迁移无关。

您的业务迁移应该如何:

Schema::create('business',

不是flights。 它关于项目表。

你必须创建一个项目迁移:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-17
    • 2017-05-26
    • 2018-06-26
    • 2020-11-21
    • 2020-11-16
    • 2023-03-17
    • 2019-03-05
    • 2020-03-11
    相关资源
    最近更新 更多