hariprasatn
4 months ago
203
4
Laravel

php artisan migrate:fresh error

Posted 4 months ago by hariprasatn

i'm getting this error

   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1005 Can't create table `a`.`customers` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `customers` add con
straint `customers_last_login_at_foreign` foreign key (`last_login_at`) references `user` (`last_login_at`) on delete cascade)

here is my code

    $table->string('company_name')->nullable();

            $table->string('email');

            $table->integer('last_login_at')->unsigned();
            $table->foreign('last_login_at')
                ->references('id')->on('user')
                ->onDelete('cascade');

            $table->string('phone')->nullable();

            $table->string('address')->nullable();

            $table->string('pic');

Please sign in or create an account to participate in this conversation.