Skip to content

Foreign Key Naming #3116

Closed
Closed

Description

@toaster33

Curious how the foreign keys order is determined when Sequelize creates the table? I thought the order is alphabetical but during testing it does not appear this way but at least the order is consistent. Guessing the order comes from Models.js rawAttributes.

Is it possible to add an attribute to foreignKey that lets us define the foreign key constraint name (i.e. fk_PerOrders)? This will help when using Sequelize migrations.

ALTER TABLE Orders
ADD CONSTRAINT fk_PerOrders
FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)

Activity

  1. added
    type: feature
    on Feb 12, 2015
  2. changed the title [-]Request Foreign Key Naming[/-] [+]Foreign Key Naming[/+] on Apr 27, 2015
  3. apsavin commented on Nov 28, 2015

    @apsavin

    +1

  4. mjurincic commented on Apr 22, 2016

    @mjurincic

    +1

  5. antonsamper commented on Jun 14, 2016

    @antonsamper

    👍

  6. KarboniteKream commented on Aug 27, 2016

    @KarboniteKream

    I also think this would be a nice feature.

  7. fabiotadashi commented on Nov 28, 2016

    @fabiotadashi

    That would be nice.

    But I also have a problem that I think it's related to this issue (Foreign Key Naming). During the migration, "add column" uses the property name to create the foreign key name, which could generate a problem (duplicate foreign key names).

  8. stale commented on Jun 29, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

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

    staletype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions