Sequelize Migrate - Error: TypeError: defineCall is not a function

0

Hi, I'm doing a simple championship API, I used Sequelize as ORM for my database.

I created the Arbitrator table that had only the NAME field and did not have the CPF field in the table.

I had to include the CPF field in the Arbitrator table and to do this I would have to use a migrate with Sequelize-CLI

After sequelize db:migrate works, to execute the project this is giving error.

But when I run my project, the following error occurs:

Hereisthecode: link

I searched the net for the cause of the error, but I'm new to NodeJs and every case was a case too.

Thank you for helping. At.

    
asked by anonymous 20.05.2017 / 18:24

1 answer

1

When you upload your project, in the db.js file it loads all your models and at line 39 it is trying to import a file that is not a "models / index.js" model.

    const dir = Path.join(__dirname, 'models'); // Nessa linha ele carrega todos arquivos que devem ser apenas suas models.
    Fs.readdirSync(dir).forEach((file) => {
        const modelDir = Path.join(dir, file);
        const model = sequelize.import(modelDir);
        db.models[model.name] = model;
    });

Try to remove this "models / index.js" file and run the project again because it is apparently not needed in the project or is in the wrong place.

    
24.05.2017 / 19:10