42703尝试使用KnexJS插入时POSTGRESQL出错

时间:2017-08-03 04:38:03

标签: javascript postgresql heroku knex.js

我一直在使用KnexJS作为维护我的数据库的框架,在开发中KnexJS使用的SQLite3没有给我任何问题,但是设置为POSTGRESQL用于生产(Heroku),这似乎对我的工作方式更加严格。

当我检查Heroku日志时,我得到的错误是:

name: 'error',
length: 121,
severity: 'ERROR',
error: insert into "users" ("city", "country", "email", "fName", "lName", 
"organisation", "password", "phone", "street_address", "suburb", 
"user_image_url") values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) - 
column "city" of relation "users" does not exist
code: '42703'

这就是我的种子的样子:

exports.seed = function(knex, Promise) {
  // Deletes ALL existing entries
  return knex('users').del()
    .then(function () {
  // Inserts seed entries
  return knex('users').insert([
    {fName: 'Person', lName: 'One', organisation: 'Company', email: 'person1@place.com', street_address: '70 King St', suburb: 'Kelburn', city:'Auckland', country: 'New Zealand', phone: 027027027, 'user_image_url': '', password: ''},
    {fName: 'Person', lName: 'Two', organisation: 'Catch22', email: 'person2@place.com', street_address: '70 Prince St', suburb: 'Ngunguru', city:'Wellington', country: 'New Zealand',  phone: 021021021, 'user_image_url': '', password: ''}
  ]);
});
};

这是我对用户的迁移。

exports.up = function(knex, Promise) {
  return knex.schema.createTable('users', function (table) {
    table.increments('id')
    table.string('fName')
    table.string('lName')
    table.integer('phone')
    table.string('password')
    table.string('email')
    table.string('street_address')
    table.string('suburb')
    table.string('organisation')
    table.string('user_image_url')
    table.string('city')
    table.string('country')
})
};

 exports.down = function(knex, Promise) {
  return knex.schema.dropTable('users')
};

有人有任何想法吗?

0 个答案:

没有答案