markitosgv / JWTRefreshTokenBundle

Implements a Refresh Token system over Json Web Tokens in Symfony
MIT License
663 stars 159 forks source link

Update from v1.1.1 to v1.1.3 leads to wrong sequence names #364

Closed Derison closed 1 year ago

Derison commented 1 year ago

Hey,

I've just upgraded the package from version 1.1.1 to version 1.1.3, but I am now getting the following error when I try to log in:

An exception occurred while executing 'SELECT NEXTVAL('refresh_tokens_id_seq')':

SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "refresh_tokens_id_seq" does not exist
LINE 1: SELECT NEXTVAL('refresh_tokens_id_seq')

I think this is because the table of the RefreshToken has a specific name:

#[ORM\Entity]
#[ORM\Table(name: 'user_refresh_tokens')]
class RefreshToken extends BaseRefreshToken
{ }

However, there is an actual workaround, as it is what the bin/console d:s:u --dump-sql suggests: Dropping the old sequence called user_refresh_tokens_id_seq and create the new like

CREATE SEQUENCE refresh_tokens_id_seq INCREMENT BY 1 MINVALUE 1 START 1;

This works, but makes it necessary to make some kind of migration for production environments because we're already running a sequence on user_refresh_tokens_id_seq.


Is there a way to avoid that, because the old sequence was made by the package in its previous version. So it seems like it is missing some kind of backwards compatibility.

mbabker commented 1 year ago

Was it only this bundle that was updated, or were other packages updated at the same time? This sounds an awful lot like https://github.com/doctrine/orm/issues/10927.

Note that there isn't anything in this bundle controlling that aspect of the database schema, that's all on the ORM.

Derison commented 1 year ago

Yeah, it wasn't the only package. I am with you, sounds like the Doctrine issue. Can be closed then. Thank you for your quick response!