Closed SimonChaumet closed 4 years ago
Are you able to change the primary key field's name from ticketCategoryId
to id
? That'd likely solve it.
The naming of the index is determined by Sequelize itself, not this module.
If you don't want to change the field name, you could alternatively create the ancestors model yourself, and define the unique index yourself with whatever name you choose.
Hope that helps.
I like to have long id names but I changed to tcId instead and it seems to work.
But the throughName option is totally ignored (I use snake case for table names) :
const TicketCategory = sequelize.define('TicketCategory', {
tcId: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true
},
name: DataTypes.STRING(64),
}, {
tableName: 'ticket_category',
hierarchy: {
throughName: 'ticket_category_ancestors'
},
});
OK. Glad it worked. Like I said, Sequelize itself is what decides the names for indexes, so that's out of my control.
Concerning your other point, there is no throughName
option. I think what you're after is throughTable
. See the docs here.
I'm closing this issue as I think it's resolved (or at least as far as this module is able to resolve it). Shout if you have further problems.
When synchronizing my model the ancestor database is created with a unique index with a name too long.
I'm using Sequelize v4.33.4, Node v10 minimum and MySQL 5.5.57.
Which parameter could be changed in order to get a shorter name ?
Server logs :
My model :
Thanks for your help.