简体   繁体   English

Laravel 第一个文件/运行后迁移失败(创建用户和密码重置表的文件除外)

[英]Laravel Migration Failed After The First File/Run(except file for creating users and password_reset table)

I tried making database using Laravel Migration, it works only in first file and run... after that, I don't know what it caused to fail.我尝试使用 Laravel 迁移制作数据库,它仅适用于第一个文件并运行...之后,我不知道它导致失败的原因。 I made date, head, and many more for the database, date successfully implemented but head fail even after I remove date migration file and using limiter on interger didn't give any effect.我为数据库制作了日期、头部和更多内容,日期成功实现,但头部失败,即使我删除了日期迁移文件并且在整数上使用限制器也没有产生任何效果。 Error Screenshot错误截图

在此处输入图像描述

.env .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mono
DB_USERNAME=root
DB_PASSWORD=

Localhost本地主机

在此处输入图像描述

create_head_table.php create_head_table.php

   <?php
    
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;
    
    class CreateHeadTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('head', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->string('head', 50);
                $table->interger('tgl', 50);
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::dropIfExists('head');
        }
    }

Pay attention to your "create_head_table.php" migration file.注意您的“create_head_table.php”迁移文件。 As of your image the error occurs on line 19 and so why?在您的图像中,错误发生在第 19 行,为什么? In the up function:up中:

public function up()
{
    Schema::create('head', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('head', 50);
        $table->interger('tgl', 50);//$table->integer('tgl'); or $table->string('tgl', 50);
    });
}

Is the last field of table integer or string ?表的最后一个字段是integer还是string If it is string so plz correct it but if it is integer your syntax is wrong.如果它是string ,请纠正它,但如果它是integer你的语法是错误的。 The second parameter in integer is autoincrement not length integer 中的第二个参数是autoincrement而不是长度

Refer Here for more information.请参阅此处了解更多信息。

You have an spelling mistake in here $table->interger('tgl', 50);你在这里有拼写错误$table->interger('tgl', 50); . . It will be integer not interger .它将是integer而不是interger

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 迁移laravel 5.5:除了users表和password_reset表之外,无法创建表 - Migration laravel 5.5 : cannot create table except users table and password_reset table ResetPasswordController 如何使用 password_reset 表 Laravel - How ResetPasswordController works with password_reset table Laravel 如何生成令牌,该令牌将在一段时间后过期,就像laravel 5.1中password_reset表中的令牌字段一样? - How can i generate a token which will expire after some time just like the token field in password_reset table in laravel 5.1? Laravel,如何将密码重置为用户表中重复的电子邮件 - Laravel, How to reset password to email where duplicated in users table laravel中第一个用户的密码重置 - Password reset for first user in laravel 带有流浪汉数据库迁移的Laravel 4“使用密码NO”重置 - Laravel 4 with vagrant database migration “using password NO” reset 在迁移文件中获取表ID(laravel 5.8) - get table id in migration file (laravel 5.8) 在Laravel代码中运行工匠而无需在表迁移中创建迁移记录 - Run artisan in Laravel code without creating migration records in the table migrations Laravel数据库迁移方法在删除迁移文件后不起作用 - Laravel database migration methods not working after deleting a migration file 任何文件更改后,Laravel连接都会重置 - Laravel connection reset after any file changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM