Laravel adding extra field in table results in General error: 2057

106
October 27, 2018, at 10:20 PM

My problem is quite simple, but I can't find any answer for this specific issue.

The thing is, I have this migration in Laravel:

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name')->unique();
        $table->string('email')->unique();
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        //$table->string('guid');
        $table->boolean('verified')->default('0');
        $table->integer('tribe_id')->length(10)->unsigned()->default('1');
        $table->boolean('admin')->default('0');
        $table->rememberToken();
        $table->timestamps();
    });
    Schema::table('users', function($table) {
        $table->foreign('tribe_id')->references('id')->on('tribes')->onDelete('cascade');
    });
}

As you can see I have one field commented. But when I remove the // and run the migration (on a clean DB) and when I try to perform login it returns this:

lluminate \ Database \ QueryException (HY000)
SQLSTATE[HY000]: General error: 2057 A stored procedure returning result sets of different size was called. This is not supported by libmysql (SQL: select * from `users` where `email` = email@email.com limit 1)

The major part of this auth code is generated by default Laravel artisan make:auth command.

The thing is, I already have some extra fields and it does work, but for some reason when I add the 'guid' new one (or another one, it doesn't matter the name) it breaks something I missing...

EDIT: It has something to do with MySQL database. I changed this from Shared Hosting MariaDB server to Google Cloud (5.7) and it's working...

EDIT2: Solved it by creating another database with another name (recreating with the same name didn't work) and it started working again...

Answer 1
Schema::table('users', function(Blueprint $table) {
    $table->foreign('tribe_id')->references('id')->on('tribes')->onDelete('cascade');
});

try to put Blueprint in table like this...

or you can put the line $table->foreign()... inside the create method..

Rent Charter Buses Company
READ ALSO
A better approach to combine multiple MySQL tables in PHP?

A better approach to combine multiple MySQL tables in PHP?

I am developing a system which generates an ID for all users that visit my websiteIf the user creates an account, applies for credit, buys a products

100
How to fix HTTP ERROR 500 cpanel - laravel

How to fix HTTP ERROR 500 cpanel - laravel

I am trying to deploy a Laravel application on a shared hosting but I am getting HTTP ERROR 500 when I try to access the web in the browser

606
Laravel auditing: change the default table name “audits”

Laravel auditing: change the default table name “audits”

Since we are using the audits table already in our project, is there any way to change the table name from "audits" to like "audit_trail_histories"?

118