0

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...

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Fred
  • 313
  • 1
  • 2
  • 11
  • I tried to make the same thing as you did, and it works fine for me. The only thing that I can notice is that for all the other extra fields you either have default value or nullable, but for guid you don't. When you say the major part of the auth code is generated, what are the changes that you have added? Because the error says that a stored procedure returns less/more values than it expects. – nakov Oct 26 '18 at 19:02
  • It says you have a stored procedure in your database. Maybe you have to modify that DB procedure to return what is expected. – newUserName02 Oct 26 '18 at 19:13
  • @nakov, I removed the default because I thought that it was that default value it was messing with this. The changes are the one you can see on the database migration, $fillable variable in User model, views blade and I changed the sendMailVerificationNotification() function. I have no idea what is the procedure that the error is referencing. – Fred Oct 26 '18 at 19:33
  • @newUserName02, the DB was clean... I have no clue. – Fred Oct 26 '18 at 19:33
  • @Fred Why do you write that foreign key constraint separately? – nice_dev Oct 26 '18 at 20:18
  • @Fred Are you sure only this file runs when you do the `php artisan migrate`? – nice_dev Oct 26 '18 at 20:22
  • @vivek_23, I don't remember but it was not working before inline on the create() func. I traced down the issue to MySQL version! I am using now Google Cloud MySQL and it's working. It's the difference between 5.6.14 and 5.7(Google Cloud), so... What can I do code-wise do sort this out? I still have no idea exactly what's causing this. – Fred Oct 26 '18 at 20:34

1 Answers1

0
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..

jld0918
  • 1
  • 1