1
votes
  1. C:\Users\lenovo\Desktop\Yoobou\Yoobou>sequelize db:migrate

    Sequelize CLI [Node: 14.15.1, CLI: 6.2.0, ORM: 6.3.5]

    Loaded configuration file "config\config.json". Using environment "development". == 20201207141344-create-producteurs: migrating =======

    ERROR: Cannot find module 'sequelize/types' Require stack:

    • C:\Users\lenovo\Desktop\Yoobou\Yoobou\migrations\20201207141344-create-producteurs.js
    • C:\Users\lenovo\AppData\Roaming\npm\node_modules\sequelize-cli\node_modules\umzug\lib\migration.js
    • C:\Users\lenovo\AppData\Roaming\npm\node_modules\sequelize-cli\node_modules\umzug\lib\index.js
    • C:\Users\lenovo\AppData\Roaming\npm\node_modules\sequelize-cli\lib\core\migrator.js
    • C:\Users\lenovo\AppData\Roaming\npm\node_modules\sequelize-cli\lib\commands\migrate.js
    • C:\Users\lenovo\AppData\Roaming\npm\node_modules\sequelize-cli\lib\sequelize

    //MIGRATION 20201207141344-create-producteurs.js

    'use strict'; const { UniqueConstraintError } = require('sequelize/types');

    module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.createTable('PRODUCTEURS', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, },

      first_name: {
        allowNull: false,
        type: Sequelize.STRING,
        unique: true,
      },
      last_name: {
        allowNull: false,
        type: Sequelize.STRING,
      },
      email: {
        allowNull: false,
        type: Sequelize.STRING,
        Unique: true,
      },
      password: {
        allowNull: false,
        type: Sequelize.STRING,
      },
      avatar: {
        allowNull: false,
        type: Sequelize.STRING,
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE,
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE,
      },
    });   },   down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('PRODUCTEURS');   }, };
    // ASSOCIATION MODELS  'use strict'; const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => {  
    

    class ADMINISTRATEUR extends Model { /** * Helper method for defining associations. * This method is not a part of Sequelize lifecycle. * The models/index file will call this method automatically. / associate(models) { // define association here models.ADMINISTRATEUR.hasMany(models.CLIENTS); models.ADMINISTRATEUR.hasMany(models.PRODUITS); models.ADMINISTRATEUR.hasMany(models.ADRESSE_CLIENTS); models.ADMINISTRATEUR.hasMany(models.CATEGORY_PRODUITS); models.ADMINISTRATEUR.hasMany(models.COMMANDES); models.ADMINISTRATEUR.hasMany(models.PRODUCTEURS); models.ADMINISTRATEUR.hasMany(models.AVIS); } } ADMINISTRATEUR.init( { first_name: DataTypes.STRING, last_name: DataTypes.STRING, email: DataTypes.STRING, password: DataTypes.STRING, avatar: DataTypes.STRING, }, { sequelize, modelName: 'ADMINISTRATEUR', } ); return ADMINISTRATEUR; }; 'use strict'; const { Model } = require('sequelize'); module.exports = (sequelize, DataTypes) => { class PRODUCTEURS extends Model { /* * Helper method for defining associations. * This method is not a part of Sequelize lifecycle. * The models/index file will call this method automatically. */ static associate(models) { // define association here models.PRODUCTEURS.belongsTo(models.ADMINISTRATEUR , { foreignKey: { allowNull: false } }); models.PRODUCTEURS.hasMany(models.CLIENTS); models.PRODUCTEURS.hasMany(models.PRODUITS); models.PRODUCTEURS.hasMany(models.ADRESSE_CLIENTS); models.PRODUCTEURS.hasMany(models.CATEGORY_PRODUITS); models.PRODUCTEURS.hasMany(models.COMMANDES); } }; PRODUCTEURS.init({ first_name: DataTypes.STRING, last_name: DataTypes.STRING, email: DataTypes.STRING, password: DataTypes.STRING, avatar: DataTypes.STRING }, { sequelize, modelName: 'PRODUCTEURS', }); return PRODUCTEURS; };

1
can you show 20201207141344-create-producteurs.js?Anatoly
@Anatoly I put it back in the questionOumar MAURET

1 Answers

0
votes

I finally found the answer I had to put the variable "const {UniqueConstraintError} = require ('sequelize / types')" in comment and retype sequelize db: migrate