【问题标题】:I cant create a new table in laravel 5?我不能在 laravel 5 中创建一个新表?
【发布时间】:2018-03-21 21:24:07
【问题描述】:

您好,我尝试创建一个新表,但我无法尝试使用 --path no response 进行迁移

class CreateParkedTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('parked', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('Equipment');
            $table->string('link');
            $table->string('latitude');
            $table->string('longitude');
            $table->timestamps();
        });
    }

当我尝试 php artisan migrate 或 php artisan migrate:refresh My table dosent create

C:\xampp\htdocs\FinalProject>php artisan make:migration create-parked-table --create=parked
Created Migration: 2018_03_21_210934_create-parked-table

C:\xampp\htdocs\FinalProject>php artisan migrate

   Illuminate\Database\QueryException  : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'clients' already exists (SQL: create table `clients` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `link` varchar(191) not null, `Equipment` varchar(191) not null, `latitude` varchar(191) not null, `longitude` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)

  at C:\xampp\htdocs\FinalProject\vendor\laravel\framework\src\Illuminate\Database\Connection.php: 664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }

     l═          ublic function         ki═          sDoctrineAvailable     ki═          ublic function  returnli═          etDoctrineColumn
kiC:\xampp\htdocs\FinalProject\vendor\laravel\framework\src\Illuminate\Database\Connection.php : 458

  2   PDOStatement::execute()
      C:\xampp\htdocs\FinalProject\vendor\laravel\framework\src\Illuminate\Database\Connection.php : 458

  Please use the argument -v to see more details.
任何想法请我需要创建另外几张表

【问题讨论】:

    标签: laravel-5


    【解决方案1】:

    Laravel 只需几个步骤即可完成迁移。

    php artisan migrate
    

    在幕后,laravel 保留了一个迁移表,它在其中跟踪运行了哪些文件,以及发生了哪些批处理。

    您的表已创建,但 laravel 没有创建提及它,因为该过程被中断/崩溃。

    您可以通过转到数据库轻松解决此问题,手动删除clients 表,然后运行php artisan migrate again

    如果您不想删除clients 表,您也可以将clientmigration 文件的名称复制到迁移表中,然后选择现有的最高批号或高1。

    【讨论】:

      猜你喜欢
      • 2015-04-24
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 2017-08-30
      • 1970-01-01
      • 2021-08-16
      • 2019-11-19
      • 1970-01-01
      相关资源
      最近更新 更多