adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
191 stars 65 forks source link

Invaid Default value of dates when set timestamps to true in migration #169

Closed venki0004 closed 3 years ago

venki0004 commented 3 years ago

Package version

Adonisjs V5

Node.js and npm version

Nodejs v15.0.0 and Npm 7.0.2

Sample Code (to reproduce the issue)

I try to run migration for api_tokens table

steps

node ace configure @adonisjs/auth
> Select provider for finding users · lucid
> Select which guard you need for authentication (select using space) · api

> Enter model name to be used for authentication · UEU
> Create migration for the ueus table? (y/N) · true
> Select the provider for storing API tokens · database   
> Create migration for the api_tokens table? (y/N) · true
node ace migration:run

Expected outcome

Migration executed successfully

Actual outcome

error database\migrations\1620384855731_api_tokens
[ error ]  create table `api_tokens` (`id` int unsigned not null auto_increment primary key, `user_id` int unsigned, `name` varchar(255) not null, `type` varchar(255) not null, `token` varchar(64) not null, `expires_at` timestamp null, `created_at` timestamp not null) - ER_INVALID_DEFAULT: Invalid default value for 'created_at'

image

swapnilnandgave commented 3 years ago

I was resolved this issue by setting default value as .defaultTo(this.now)

thetutlage commented 3 years ago

Closing fixed in https://github.com/adonisjs/auth/commit/335e52b029742c5ae18c8a4ae08485d2b7bd542d