Skip to content

moving model.associate outside classMethods due to sequelize@4.0.0 - #470

Closed
geluso wants to merge 2 commits into
sequelize:masterfrom
geluso:master
Closed

geluso wants to merge 2 commits into
sequelize:masterfrom
geluso:master

Conversation

@geluso

@geluso geluso commented Jun 16, 2017

Copy link
Copy Markdown

I'm trying to figure out if sequelize-cli is supposed to match breaking changes introduced in sequelize@4.0.0. If yes, the model.associate method needs to be moved outside classMethods because classMethods was removed in sequelize@4.0.0.

Review my comment here: #468

@wayne-o

wayne-o commented Jul 17, 2017

Copy link
Copy Markdown

This desperately needs to be merged in :/

@sushantdhiman

Copy link
Copy Markdown
Contributor

This will be a breaking change, so can't release to v3

@sushantdhiman sushantdhiman added this to the v4.0.0 milestone Jul 23, 2017
@wayne-o

wayne-o commented Jul 23, 2017

Copy link
Copy Markdown

I figured out the modification that needs to happen - all good in the interim :)

@sushantdhiman

Copy link
Copy Markdown
Contributor

I will post sample from v4 upgrade guide for others
http://docs.sequelizejs.com/manual/tutorial/upgrade-to-v4.html

Previous :

const Model = sequelize.define('Model', {
    ...
}, {
    classMethods: {
        associate: function (model) {...}
    },
    instanceMethods: {
        someMethod: function () { ...}
    }
});

New :

const Model = sequelize.define('Model', {
    ...
});

// Class Method
Model.associate = function (models) {
    ...associate the models
};

// Instance Method
Model.prototype.someMethod = function () {..}

@sushantdhiman sushantdhiman mentioned this pull request Jul 23, 2017
14 of 21 tasks
@geluso

geluso commented Jul 24, 2017

Copy link
Copy Markdown
Author

@sushantdhiman thank you for a direct clarifying response and clear progress forward!

@mandreko

Copy link
Copy Markdown

I'm all for this change. I just spent an evening trying to figure out why my models and relationships were not working. I eventually compared the generated code from the cli to the example site to see the difference in the models.

@buddylindsey

Copy link
Copy Markdown
Contributor

@sushantdhiman What would it take to get this merged? If @geluso doesn't want to fix the merge conflict could I branch off of his and fix it and create a new PR? Or if @geluso does fix the merge conflict is that all it would take to merge?

Was wanting to see if I could help a bit move cli v4 along.

@sushantdhiman

Copy link
Copy Markdown
Contributor

@buddylindsey Please open a new branch and I will merge it, I am unable to find some time to complete #441 so let's fix incompatibilities first then think about other features

codetriage-readme-bot pushed a commit to codetriage-readme-bot/cli that referenced this pull request Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants