Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 700
Chipmaster5 Avatar asked May 15 '26 06:05

Chipmaster5


2 Answers

While the solution from Chipmaster5 works, I think it's a bad idea to use mysql dialect, if you're using a mariadb image. Specifically this problem seems to be introduced with v3 of the mariadb package, reverting to 2.x resolved the problem for me.

like image 151
nn3112337 Avatar answered May 19 '26 04:05

nn3112337


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!

like image 35
Chipmaster5 Avatar answered May 19 '26 02:05

Chipmaster5