FIX TOO MANY KEYS ISSUE PLSS

This commit is contained in:
Rykkel
2024-08-12 14:58:04 +08:00
parent 22e778e907
commit dd1d84d22a
2 changed files with 19 additions and 13 deletions

View File

@@ -24,18 +24,18 @@ module.exports = (sequelize, DataTypes) => {
}, { }, {
tableName: 'post_tags', tableName: 'post_tags',
timestamps: false, timestamps: false,
indexes: [ // indexes: [
{ // {
unique: true, // unique: true,
fields: ['postId', 'tagId'] // Composite unique index // fields: ['postId', 'tagId'] // Composite unique index
}, // },
{ // {
fields: ['postId'] // Index for efficient querying // fields: ['postId'] // Index for efficient querying
}, // },
{ // {
fields: ['tagId'] // Index for efficient querying // fields: ['tagId'] // Index for efficient querying
} // }
] // ]
}); });
return PostTag; return PostTag;

View File

@@ -9,11 +9,17 @@ module.exports = (sequelize, DataTypes) => {
tag: { tag: {
type: DataTypes.STRING(30), type: DataTypes.STRING(30),
allowNull: false, allowNull: false,
unique: true, // Ensure tags are unique
}, },
}, { }, {
tableName: 'tags', tableName: 'tags',
timestamps: false, timestamps: false,
// indexes: [
// {
// unique: true,
// fields: ['tag'], // Unique index on the tag column
// name: 'unique_tag_index', // Explicitly naming the index
// }
// ]
}); });
Tag.associate = (models) => { Tag.associate = (models) => {