Can't drop a column in a migration
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, mariadb, mysql
- Domain
- databases
Research direction
Start by reproducing the migration's queryInterface.removeColumn call against MariaDB 10.7, using the SQL and error shown in the issue. Trace the removeColumn implementation and its constraint lookup, then verify that the migration completes and the id_Sage column is dropped without the reported error.
Written by the indexing model from the issue text.
Description
What you are doing?
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.removeColumn('user', 'id_Sage', {
logging: (sql) => console.error(sql),
});
},
async down(queryInterface, Sequelize) {
return false;
},
};
What do you expect to happen?
I expected the column to be dropped
What is actually happening?
An error occurs which prevents me from migrating my DB
▶ yarn run db:migrate
yarn run v1.22.19
$ sequelize db:migrate
Sequelize CLI [Node: 18.14.0, CLI: 6.6.0, ORM: 6.6.5]
Loaded configuration file "libs/db/src/config/database/index.js".
Using environment "development".
== 20230224101241-remove-idSage-from-user: migrating =======
Executing (default): SELECT CONSTRAINT_NAME as constraint_name,CONSTRAINT_NAME as constraintName,CONSTRAINT_SCHEMA as constraintSchema,CONSTRAINT_SCHEMA as constraintCatalog,TABLE_NAME as tableName,TABLE_SCHEMA as tableSchema,TABLE_SCHEMA as tableCatalog,COLUMN_NAME as columnName,REFERENCED_TABLE_SCHEMA as referencedTableSchema,REFERENCED_TABLE_SCHEMA as referencedTableCatalog,REFERENCED_TABLE_NAME as referencedTableName,REFERENCED_COLUMN_NAME as referencedColumnName FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE (REFERENCED_TABLE_NAME = 'user' AND REFERENCED_TABLE_SCHEMA = 'database' AND REFERENCED_COLUMN_NAME = 'id_Sage') OR (TABLE_NAME = 'user' AND TABLE_SCHEMA = 'database' AND COLUMN_NAME = 'id_Sage' AND REFERENCED_TABLE_NAME IS NOT NULL)
ERROR: Cannot delete property 'meta' of [object Array]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Dialect: mysql/mariadb
Database version: 10.7
Sequelize CLI version: 6.6.0
Sequelize version: 6.6.5
- Dominant language
- JavaScript
- Stars
- 2.6k
- Forks
- 524
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sequelize/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·