module.exports = {
  up: (queryInterface, Sequelize) => queryInterface.createTable('Messages', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER
    },
    content: {
      type: Sequelize.STRING
    },
    createdAt: {
      allowNull: false,
      type: Sequelize.DATE
    },
    updatedAt: {
      allowNull: false,
      type: Sequelize.DATE
    },
    userId: {
      type: Sequelize.INTEGER,
      onDelete: 'CASCADE'
    },
    groupId: {
      type: Sequelize.INTEGER,
      onDelete: 'CASCADE'
    },
  }),
  down(queryInterface /* , Sequelize */) {
    queryInterface.dropTable('Messages');
  }
};


module.exports = {
  up: (queryInterface, Sequelize) => queryInterface.createTable('Messages', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER
    },
    content: {
      type: Sequelize.STRING
    },
    createdAt: {
      allowNull: false,
      type: Sequelize.DATE
    },
    updatedAt: {
      allowNull: false,
      type: Sequelize.DATE
    },
    userId: {
      type: Sequelize.INTEGER,
      onDelete: 'CASCADE',
      references: {
        model: 'Users',
        key: 'id',
        as: 'userId',
      },
    },
    groupId: {
      type: Sequelize.INTEGER,
      onDelete: 'CASCADE',
      references: {
        model: 'Groups',
        key: 'id',
        as: 'groupId',
      },
    },
  }),
  down(queryInterface /* , Sequelize */) {
    queryInterface.dropTable('Messages');
  }
};


--- 
+++ 
@@ -19,21 +19,11 @@
     },
     userId: {
       type: Sequelize.INTEGER,
-      onDelete: 'CASCADE',
-      references: {
-        model: 'Users',
-        key: 'id',
-        as: 'userId',
-      },
+      onDelete: 'CASCADE'
     },
     groupId: {
       type: Sequelize.INTEGER,
-      onDelete: 'CASCADE',
-      references: {
-        model: 'Groups',
-        key: 'id',
-        as: 'groupId',
-      },
+      onDelete: 'CASCADE'
     },
   }),
   down(queryInterface /* , Sequelize */) {
Delete references field to fix userId and groupId bugs
