Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5.2.14 UUID used for ID Column instead of Illuminate\Database\Schema\Blueprint::increments Unsigned Integer #28

Open
mtpultz opened this issue Feb 12, 2016 · 0 comments
Labels

Comments

@mtpultz
Copy link
Contributor

mtpultz commented Feb 12, 2016

Using this migration and seed, the ID of the inserted row data is a UUID instead of an unsigned integer. I noticed after stubbing through the code for a couple hours trying to find out why an authenticated user couldn't access authenticated routes. The user ID was 8 when there was only 3 users seeded, and it turns out the 8 was just the first digit from the UUID string.

use duxet\Rethinkdb\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {

    public function up()
    {
        Schema::create('users', function(Blueprint $table) {
            $table->increments('id');
            ...
        });
    }

    ...
}

Using RethinkDB Blueprint create doesn't implement the Laravel Blueprint API, which includes a version of the increments method.

/**
 * Create a new auto-incrementing integer (4-byte) column on the table.
 *
 * @param  string  $column
 * @return \Illuminate\Support\Fluent
 */
public function increments($column)
{
    return $this->unsignedInteger($column, true);
}

Produces this in RethinkDB's admin panel for this ReQL statement r.db('app').table('users'):

{
"created_at": Fri Feb 12 2016 10:04:22 GMT+00:00 ,
"email": test@test.com, »
"id":  "8bbc1c35-6be5-4b1f-87de-75eba1c459eb" ,
"password":  "$2y$10$2f7QjuBCjEMr3R01ZNlwI.ft8v8FYs8IHRQzPI1lKdojIXtK7b9wO" ,
"role":  "admin" ,
"updated_at": Fri Feb 12 2016 10:04:22 GMT+00:00 ,
"username":  "test"
}

So unless the ID is explicitly set to a unsigned integer it becomes a UUID, which prevents access to routes. The simplest solution might be to have a config for adding UUID to Laravel similar to this implementation or this one.

@mtpultz mtpultz changed the title Laravel 5.2.14 Middleware Appears to Prevent Login Laravel 5.2.14 Middleware Prevents Proper Authentication Feb 12, 2016
@mtpultz mtpultz changed the title Laravel 5.2.14 Middleware Prevents Proper Authentication Laravel 5.2.14 Authentication Redirect Seen as Guest in Home Route Feb 12, 2016
@mtpultz mtpultz changed the title Laravel 5.2.14 Authentication Redirect Seen as Guest in Home Route Laravel 5.2.14 Authentication Redirect User Seen as Guest in Home Route Feb 12, 2016
@mtpultz mtpultz changed the title Laravel 5.2.14 Authentication Redirect User Seen as Guest in Home Route Laravel 5.2.14 UUID used instead of Illuminate\Database\Schema\Blueprint::increments Unsigned Integer Feb 13, 2016
@mtpultz mtpultz changed the title Laravel 5.2.14 UUID used instead of Illuminate\Database\Schema\Blueprint::increments Unsigned Integer Laravel 5.2.14 UUID used for ID Column instead of Illuminate\Database\Schema\Blueprint::increments Unsigned Integer Feb 13, 2016
@duxet duxet added the bug label Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants