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

when i sync table cant create index when i rename field name

Open KingDracula opened this issue 4 years ago • 2 comments

Issue

Versions

  • sequelize:
  • sequelize-typescript:
  • typescript:

Issue type

  • [x] bug report
  • [ ] feature request

Actual behavior

Expected behavior

Steps to reproduce

Related code

image image

insert short code snippets here

KingDracula avatar Nov 01 '21 07:11 KingDracula

Has someone found any solution for this? As far I see db sync must be disabled to workaround this and everything should be done in migration scripts.

avoylenko avatar May 09 '22 20:05 avoylenko

2 years, no progress on this issue...

The workaround is to avoid using @Index decorator. So there are 3 ways to add index:

  1. manually
  2. through migration
  3. describe indexies in @Table decorator options.
@Table({
    underscored: true,
    timestamps: true,
    tableName: 'wrf_sequelize',
    indexes: [
        { fields: ['your_awesome_underscored_field_name']}
    ]
})

alexey-sh avatar Nov 18 '23 18:11 alexey-sh