【发布时间】:2019-03-04 18:17:28
【问题描述】:
这是我的 customer_schema.js 文件:
up () {
this.create('customers', (table) => {
table.increments()
table.string('name', 30)
})
}
CustomerSeed.js:
class CustomerSeeder {
async run () {
const customer = await Factory
.model('App/Models/Customer')
.create()
console.log('customer: ')
}
}
Customer.js 模型是“空的”
我运行迁移,一切正常,但无法运行种子:adonis seed 抛出此错误消息:
code: 'ER_BAD_FIELD_ERROR',
errno: 1054,
sqlMessage: "Unknown column 'created_at' in 'field list'",
sqlState: '42S22',
index: 0,
sql:
"insert into `customers` (`created_at`, `name`, `updated_at`) values ('2019-03-04 20:01:17', 'Peter Walsh', '2019-03-04 20:01:17')" }
为什么会这样?我什至没有在我的架构文件中声明 table.timestamps() 并且:
describe customers;
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(30) | YES | | NULL | |
+-------+------------------+------+-----+---------+----------------+
2 rows in set (0.01 sec)
【问题讨论】:
标签: javascript mysql node.js adonis.js