sequelize icon indicating copy to clipboard operation
sequelize copied to clipboard

No documentation of foreign keys (references) on Seeds

Open Solitaryo opened this issue 9 years ago • 1 comments

Right now i'm very frustrated about the seeds, i can't create a seed who works with foreign keys, i read all the issues here and nothing works or help me to guide me, this is my file:


module.exports = {
  up: function (queryInterface, Sequelize) {
    return queryInterface.bulkInsert('Projects', [{
      idUser: 1,
      name: 'Test text',
      description: 'Text test demonstration',
      enabled: true,
      properties: JSON.stringify({"api_url": "api_text", "account_type": "basic"}),
      createdAt: new Date,
      updatedAt: new Date
    }], {});
  },
};

Where my idUser is my foreign key. And yes, i have data created for that user, and yes, that id already exist in Users table.

I see that Sequelize value has .Associations, but no idea how to use it in this situation, any advice?.

I'm using:

"sequelize": "^3.29.0",
"sequelize-cli": "^2.5.1"

And the error i got is:

Seed file failed with error: column "properties" of relation "Projects" does not exist.

Thanks for your help.

Solitaryo avatar Feb 02 '17 07:02 Solitaryo

This has nothing to do with idUser or associations. The error message pretty clearly tells you, that the properties column does not exist on the Projects table.

Please open a new issue with a SSCCE if you still have issues

janmeier avatar Feb 08 '17 13:02 janmeier