Error when trying to run adonis JS migration
Error is displayed when trying to run the migration.
I'm using the migration created by Adonis Auth himself. In which the token table is created.
The error is shown when trying to create this table and mariadb immediately closes.
I'm using mysql2
Prerequisites
- Install lucid and auth
- Run migration:run
Package version
{
"name": "backend",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "node ace serve --watch",
"build": "node ace build --production",
"start": "node server.js",
"lint": "eslint . --ext=.ts"
},
"eslintConfig": {
"extends": [
"plugin:adonis/typescriptApp"
]
},
"eslintIgnore": [
"build"
],
"devDependencies": {
"@adonisjs/assembler": "^5.8.1",
"@japa/preset-adonis": "^1.2.0",
"@japa/runner": "^2.2.1",
"adonis-preset-ts": "^2.1.0",
"eslint": "^8.23.1",
"eslint-plugin-adonis": "^2.1.1",
"pino-pretty": "^9.1.0",
"typescript": "~4.6",
"youch": "^3.2.2",
"youch-terminal": "^2.1.5"
},
"dependencies": {
"@adonisjs/auth": "^8.2.2",
"@adonisjs/core": "^5.8.6",
"@adonisjs/lucid": "^18.1.1",
"@adonisjs/repl": "^3.1.11",
"crypto-js": "^4.1.1",
"luxon": "^3.0.3",
"mysql2": "^2.3.3",
"phc-argon2": "^1.1.3",
"proxy-addr": "^2.0.7",
"reflect-metadata": "^0.1.13",
"source-map-support": "^0.5.21"
}
}
Node.js and npm version
v16.15.0
Sample Code (to reproduce the issue)
Default auth token code
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class ApiTokens extends BaseSchema {
protected tableName = 'api_tokens'
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary()
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
table.string('name').notNullable()
table.string('type').notNullable()
table.string('token', 64).notNullable().unique()
/**
* Uses timestampz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('expires_at', { useTz: true }).nullable()
table.timestamp('created_at', { useTz: true }).notNullable()
})
}
public async down() {
this.schema.dropTable(this.tableName)
}
}
node ace migration:run [ info ] Upgrading migrations version from "1" to "2" ❯ migrated database/migrations/1663627357202_users ❯ error database/migrations/1663627357216_api_tokens
Error
Connection lost: The server closed the connection.
1 Socket.
Can you please reproduce this issue in a new project and share the repo with us?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.