nejdetkadir/devise-api

ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR: null value in column "resource_owner_id" of relation "devise_api_tokens" violates not-null constraint

Closed this issue · 3 comments

Hello everyone, I have an issue setting up this gem, I follow the instructions and when I try to create a new user I got this error (see the title) the resource_owner_id is null, and if you can see the image attached, when the transaction starts the user is created, I will leave here my model and other things, any help I will really appreciate!

User Model:

Screenshot from 2023-03-27 20-04-58

Schema:

Screenshot from 2023-03-27 20-06-21

image

Error:

Screenshot from 2023-03-27 19-58-27
Screenshot from 2023-03-27 19-58-47

resource_owner_id field is uuid on your devise_api_tokens table, please change column type as your default primary key type

resource_owner_id field is uuid on your devise_api_tokens table, please change column type as your default primary key type

Yeap that works thank you !

Hi,

i've tried to do what you suggest. I've created a new migration :

class ChangeUuidColumnType < ActiveRecord::Migration[7.0] def change change_column :devise_api_tokens, :resource_owner_id, :primary_key end end

and I get this error :

== 20230529143952 ChangeUuidColumnType: migrating =============================
-- change_column(:devise_api_tokens, :resource_owner_id, :primary_key)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::SyntaxError: ERROR: syntax error at or near "primary"
LINE 1: ..." ALTER COLUMN "resource_owner_id" TYPE bigserial primary ke...

Did I miss something ?