Skip to content

Fix issue with Sequelize causing indexes to be generated whenever the backend is ran #51

@jrohrbaugh0812

Description

@jrohrbaugh0812

As a developer, I want to make sure I can run the backend without causing a new index to be created in certain tables.

Tasks:

  • This issue is happening because of the app.js file in ycphacks-api. This file uses sequelize.sync() with the “alter: true” option. When Sequelize runs in “alter” mode, it generates multiple ALTER TABLE statements over time, which can create duplicate indexes, especially on columns with UNIQUE constraints (e.g., email in the User table). Eventually, MySQL reaches its limit of 64 indexes per table, causing sync errors.
  • We will need to talk about how to fix this, but one idea is to add a .env variable that each person can individually set to “alter”, “force”, or “none”, depending on what they want Sequelize to do. In this setup, you would only want to use “alter”/”force” when you just pulled in new changes from main that made changes to the Sequelize model files. To fix duplicate indexes, you would set this .env variable in all other cases to “none”.

Milestone: Stretch Goal

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions