DEV Community

Beaver Bridge
Beaver Bridge

Posted on

[Sequelize + mariaDB] index 걸린 컬럼 삭제하기

index가 걸린 필드를 삭제할 때 Cannot drop index 'notices_approval_id_foreign_idx': needed in a foreign key constraint 에러가 뜬다.

async down(queryInterface, Sequelize) {
  await queryInterface.sequelize.query(
    "ALTER TABLE notices DROP CONSTRAINT if exists notices_approval_id_foreign_idx",
  );
  await queryInterface.sequelize.query("ALTER TABLE notices DROP COLUMN if exists approval_id");
}
Enter fullscreen mode Exit fullscreen mode

원래는 removeConstraint, removeColumn 을 사용해야하는데, 안돼서 쿼리를 직접 사용해야 한다.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay