sequelize-mig icon indicating copy to clipboard operation
sequelize-mig copied to clipboard

Support Partial Indexes

Open mhaddon opened this issue 3 years ago • 1 comments

This tool is great, but it does not seem to be able to support partial indexes. Eg:

  indexes: [
    {
      unique: true,
      fields: ['col1', 'col2'],
      where: {
        deletedAt: null
      }
    }
  ]

mhaddon avatar Mar 22 '22 14:03 mhaddon

I had a look and the whole reason it wasnt working, was this line here:

https://github.com/MRVMV/sequelize-mig/blob/94ae0fbb20fc535b0829fbbc71caab2948d23b09/lib/models.js#L138

that if statement breaks the ability for this tool to correctly generate indexes

if i comment it out, everything seems to magically work, what is the point of this statement?

also i imagine we need:

if (idx.where) options.where = idx.where; here:

https://github.com/MRVMV/sequelize-mig/blob/94ae0fbb20fc535b0829fbbc71caab2948d23b09/lib/parser.js#L27

mhaddon avatar Apr 30 '22 21:04 mhaddon