Issue upgrading to Sequelize v6.3.5

Expected behavior

When running yarn start, forest recognizes Sequelize models.

Actual behavior

Error on startup: “Model creation error: TypeError: sequelize.import is not a function”

Failure Logs

Model creation error: TypeError: sequelize.import is not a function

Context

    "chalk": "~4.1.0",
    "cookie-parser": "1.4.5",
    "cors": "2.8.5",
    "debug": "~4.2.0",
    "dotenv": "~6.1.0",
    "express": "~4.17.1",
    "express-jwt": "5.3.1",
    "forest-express-sequelize": "^6.3.13",
    "lumber-cli": "^3.7.2",
    "luxon": "^1.25.0",
    "morgan": "1.10.0",
    "pg": "~8.4.1",
    "require-all": "^3.0.0",
    "sequelize": "~5.15.1"
  • Database Dialect: postgres
  • Database Version: 13
  • Project Name: Darwin

We found the issue.

It was the line var model = sequelize['import'](path.join(__dirname, file)); in models/index.js generated by lumber.

To fix this, you need to replace this line with:
var model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);

2 Likes

Hi @Thomas_Pucci,
Welcome to the Forest Admin community!

Thanks for your response.
I hope it will help other developers that would like to do the same upgrade to Sequelize v6.