javascriptnode.jsdatabasesequelize.js

Node.js Sequelize: Cannot delete property 'meta' of [object Array]


I'm learning the Sequelize.js framework and it's pretty awesome. But when I try to remove a column from my test tables in in my migration file, I get this error:

ERROR: Cannot delete property 'meta' of [object Array]

This error occurs when I use the removeColumn function from the query interface but I don't have an idea why ...

My migration file:

'use strict';

const {DataTypes} = require("sequelize");
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    return queryInterface.sequelize.transaction(t => {
      return Promise.all([
        queryInterface.removeColumn('Students', 'bloodStatus', {transaction: t}),
      ]);
    });
  },

  async down (queryInterface, Sequelize) {
    return queryInterface.sequelize.transaction(t => {
      return Promise.all([
        queryInterface.addColumn('Students', 'bloodStatus', {
          type: DataTypes.STRING,
          allowNull: false
        }, {transaction: t}),
      ]);
    });
  }
};

I used the migration file above but I get the error

ERROR: Cannot delete property 'meta' of [object Array]

I read the documentation and tried to find a solution, but unfortunately I can't find one.


Solution

  • I found the solution! I use a MariaDB in a docker container (10.11.2-MariaDB-1:10.11.2+maria~ubu2204 - mariadb.org binary distribution) and the dialect in the config.json was set to mariadb as shown in the code example below:

    {
      "development": {
        "username": "christian_cornwall",
        "password": "hogwarts",
        "database": "hogwarts_sequelize",
        "host": "172.17.0.3",
        "dialect": "mariadb"
      },
      "test": {
        "username": "root",
        "password": null,
        "database": "database_test",
        "host": "127.0.0.1",
        "dialect": "mariadb"
      },
      "production": {
        "username": "root",
        "password": null,
        "database": "database_production",
        "host": "127.0.0.1",
        "dialect": "mariadb"
      }
    }
    

    After changing the dialect settings to mysql (if you don't have the package installed, it'll ask you to install mysql2 via npm) the error's gone and the removeColumn function works. I hope this will help somebody!