Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unique: true does not generate same index name and constraint in model and migrations #17312

Open
3 of 6 tasks
qfarizon-qftech opened this issue May 6, 2024 · 0 comments
Open
3 of 6 tasks
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug

Comments

@qfarizon-qftech
Copy link

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

Considering model definition :

export class Product {
  @Attribute(DataTypes.STRING)
  @NotNull
  @Unique
  declare slug: CreationOptional<string>
}

When synced, it generates a index with name products_slug_unique

In migration :

await queryInterface.createTable('products', {
   slug: {
      type: Sequelize.DataTypes.STRING,
      allowNull: false,
      unique: true
    },

generates an index with name products_slug_key (and an additional constraint also named products_slug_key)

What do you expect to happen?

It should be consistent

Environment

  • Sequelize version: 7.0.0-alpha.37
  • Node.js version:20.9.0
  • Database & Version: pg 16
  • Connector library & Version: pg 8.11.3

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

@qfarizon-qftech qfarizon-qftech added pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug labels May 6, 2024
@qfarizon-qftech qfarizon-qftech changed the title unique: true does not generate same index name in model and migrations unique: true does not generate same index name and constraint in model and migrations May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug
Projects
None yet
Development

No branches or pull requests

1 participant