I am currently building an app using the KnexJS framework that helps me to write sqlite3 in development and postgresql in production (for Heroku).
My main issue is that my application works fine when on my machine, but as soon as I upload it to heroku it breaks. In Heroku logs I get the message:
{ error: insert into "contracts" ("contract_desc", "contract_header", "owner_id", "signee_id") values ($1, $2, $3, $4) - duplicate key value violates unique constraint "contracts_pkey"
And it leaves me unable to insert data into my database.
My Knex migrations for the table are setup like this:
exports.up = function(knex, Promise) {
return knex.schema.createTable('contracts', function (table) {
table.increments('id').primary()
table.integer('owner_id')
table.integer('signee_id')
table.string('contract_header')
table.text('contract_desc')
table.string('signature_url')
table.string('date_signed')
table.boolean('isSigned')
})
};
exports.down = function(knex, Promise) {
return knex.schema.dropTable('contracts')
};
And the function I am calling to insert the data looks like this:
function newContract (id, contractDetails) {
return knex('contracts')
.select('owner_id', 'signee_id', 'contract_header', 'contract_desc')
.insert({
owner_id: id,
signee_id: contractDetails.signee_id,
contract_header: contractDetails.contract_header,
contract_desc:contractDetails.contract_desc
})
}
Any ideas on what could be causing this?