Hi,
I've an User model which has an not incremental primary key (it's based on uuid). I am trying to integrate it with passports OAuth server. Unfortunately, I am facing with the error below where I am trying to create a secret for any user:
Invalid text representation: 7 ERROR: invalid input syntax for integer: "d4d52a80-c212-4ab4-823b-c62c3b814c2e"
I am using an Postgresql as a database. Sure, I know.. I can ignore the migration files and change it manually from the db but it's might be a compatibility issue
In the default Passport migrations, you have to set the user foreign key to 'uuid'.
@kaankilic You must change the user_id in oauth_access_tokens to uuid type, follow this steps:
Create one migration to alter the table oauth_access_tokens:
php artisan make:migration alter_table_oauth_access_tokens
Drop the collumn user_id and re-create as uuid type:
public function up()
{
Schema::table('oauth_access_tokens', function (Blueprint $table) {
$table->dropColumn('user_id');
});
Schema::table('oauth_access_tokens', function (Blueprint $table) {
$table->uuid('user_id')->index()->nullable();
});
}
Closing for lack of activity, hope you got the help you needed :)
In case someone else comes upon this - make sure you have $incrementing = false; in your User Model, otherwise the user_id won't save properly.
to me throws an error, because first execute this new migration, so not found the oauth_access_tokens table. someone help me, pls
Most helpful comment
@kaankilic You must change the
user_idinoauth_access_tokensto uuid type, follow this steps:Create one migration to alter the table
oauth_access_tokens:php artisan make:migration alter_table_oauth_access_tokensDrop the collumn
user_idand re-create as uuid type: