Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

699
Views
error: column "..." of relation "..." does not exist

I'm using PostgreSQL with Sequelize in Nodejs. There are 3 tables: tc_user_intervention, tc_interventions and tc_users. tc_user_intervention has 2 fields: userid (from tc_users) and interventionid (from tc_interventions). Here's the Sequelize model (auto-generated from the existing database):

const UserIntervention =  sequelize.define('tc_user_intervention', {
    userid: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'tc_users',
        key: 'id'
      }
    },
    interventionid: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'tc_interventions',
        key: 'id'
      }
    }
  }, {
    sequelize,
    tableName: 'tc_user_intervention',
    schema: 'public',
    timestamps: false
  });

If I try to do a raw query, everything works, I can insert a new raw into tc_user_interventions:

INSERT INTO `tc_user_intervention`
VALUES (value1, value2);

But if I try to do the same query with Sequelize, I receive the error:

 error: column "id" of relation "tc_user_intervention" does not exist

The query simply is:

UserIntervention.create({ 'userid': user, 'interventionid': intervention});

But Sequelize translate this query into:

sql:
      'INSERT INTO "public"."tc_user_intervention" ("id","userid","interventionid") VALUES (DEFAULT,$1,$2) RETURNING "id","userid","interventionid";',

and obviously this give me the error, because the id column does not exist neither in the model nor in the database. Why is this happening?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!