I started off by creating my basic models and relationships, including the users table. I then followed the documentation to add authentication.
The Auth Migration that is created by the invoke @adonisjs/auth command is created with the incorrect date. Some investigation shows that this is coming from adonisjs/auth/instructions.ts.
There is a hard coded string value given the dates on lines 37 & 38.
These hard-coded dates mean that if you use this invoke command to create the token table but NOT the users table you end up with invalid migrations.
To be honest I fail to see why these are hard coded at all. It's not necessary, and arguably incorrect. The migration is run at the time the migration is run - ${Date.now()}_${state.tokensTableName}.ts on line seems to be a far more reasonable solution.
Package version
Unclear - whatever node ace executes.
Node.js and npm version
Node: v12.19.0
NPM: 6.14.8
Sample Code
This should be reproducible by simply doing the following - assuming a new Adonis application has been created.
node ace make:model User -m
npm i @adonisjs/auth@alpha
node ace invoke @adonisjs/auth // select yes to creating migration
Given that the migrations will be run in order, this will undoubtedly try to run out of order, adding a foreign key onto a table that does not exist. And indeed:
[ error ] alter table "api_tokens" add constraint "api_tokens_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete CASCADE - relation "users" does not exist
I started off by creating my basic models and relationships, including the users table. I then followed the documentation to add authentication.
The Auth Migration that is created by the
invoke @adonisjs/auth
command is created with the incorrect date. Some investigation shows that this is coming from adonisjs/auth/instructions.ts.There is a hard coded string value given the dates on lines 37 & 38.
These hard-coded dates mean that if you use this invoke command to create the token table but NOT the users table you end up with invalid migrations.
To be honest I fail to see why these are hard coded at all. It's not necessary, and arguably incorrect. The migration is run at the time the migration is run -
${Date.now()}_${state.tokensTableName}.ts
on line seems to be a far more reasonable solution.Package version
Unclear - whatever
node ace
executes.Node.js and npm version
Node: v12.19.0 NPM: 6.14.8
Sample Code
This should be reproducible by simply doing the following - assuming a new Adonis application has been created.
Note that the following migrations were created:
Given that the migrations will be run in order, this will undoubtedly try to run out of order, adding a foreign key onto a table that does not exist. And indeed: