Skip to content

removeIndex not working with schema #10952

Description

@sm2017

What are you doing?

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.addIndex({
      tableName: 'user',
      schema: 'core',
    }, [
      'username',
    ]);
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.removeIndex({
      tableName: 'user',
      schema: 'core',
    }, [
      'username',
    ]);
  },
};

To Reproduce
Steps to reproduce the behavior:

  1. run migraion
  2. undo migration

What do you expect to happen?

add and remove index

What is actually happening?

index not removed

the query generated in wrong

 DROP INDEX IF EXISTS "[object _object]_username"

Environment

Dialect:

  • mysql
  • postgres
  • sqlite
  • mssql
  • any
    Dialect library version: 7.11.0
    Database version: PostgreSQL 11.2, compiled by Visual C++ build 1914, 64-bit
    Sequelize version: 5.8.6
    Node Version: 10.15.3
    OS: Windows 10
    If TypeScript related: TypeScript version: XXX
    Tested with latest release:
  • No
  • Yes, specify that version:

Activity

  1. papb commented on Aug 1, 2019

    @papb
    Member

    What SQL query should have been generated instead?

  2. added
    dialect: postgres
    status: awaiting response
    type: bug
    on Aug 1, 2019
  3. sm2017 commented on Aug 1, 2019

    @sm2017
    Author
     DROP INDEX IF EXISTS "core"."users_username"
    

    OR

     DROP INDEX IF EXISTS core.users_username
    
  4. added and removed
    status: awaiting response
    on Aug 1, 2019
  5. alesmenzel commented on Mar 13, 2020

    @alesmenzel

    Can you fix this please and include object { tableName: 'xxx', schema: 'yyy' } instead of just tableName and generate a query DROP INDEX IF EXISTS "core"."users_username" ?

  6. github-actions commented on Nov 10, 2021

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

  7. drinksbydrew commented on Nov 16, 2022

    @drinksbydrew

    Is there any progress on this issue?

  8. self-assigned this
    on Nov 16, 2022
  9. linked a pull request that will close this issuefeat: migrate index to typescript #16227on Feb 2, 2024
  10. removed their assignment
    on Feb 2, 2024
  11. sergionsz commented on Jun 4, 2024

    @sergionsz

    As a workaround, removing the index works for me using schema.table:

    await queryInterface.removeIndex('schema.table', ['column'])
    
  12. added theissue type on Mar 9, 2025
  13. removed
    type: bug
    on Mar 9, 2025
  14. boomlinde commented on Jun 1, 2026

    @boomlinde

    If this doesn't work and hasn't worked for five years you should at least document the broken behavior. I've been staring myself blind at this problem for an hour and there's no indication whatsoever in the official documentation that it's known to be broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: postgres

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions