我有一个问题,不太理解如何在AdonisJS中创建UUID。我的数据库使用的是MySQL。当我启动服务器并发布数据时,这个id_customer输出仍然是自增模式。请问有谁可以帮我解决这个问题吗?
这是我迁移文件中的架构代码:
async up () {
await this.db.raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";')
}
up () {
this.create('customers', (table) => {
table.increments()
table.uuid('id_customer').primary().defaultTo(this.db.raw('uuid_generate_v4()'))
table.timestamps()
})
}