[英]Error when trying to run adonis JS migration
尝试运行迁移时显示错误。
我正在使用 Adonis Auth 自己创建的迁移。 在其中创建令牌表。
尝试创建此表时显示错误,mariadb 立即关闭。
我正在使用 mysql2
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.<anonymous>
..../node_modules/mysql2/lib/connection.js:101
我建议在运行迁移之前重新启动服务器node ace serve --watch
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.