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',
timestamps: false,
indexes: [
{
unique: true,
fields: ['postId', 'tagId'] // Composite unique index
},
{
fields: ['postId'] // Index for efficient querying
},
{
fields: ['tagId'] // Index for efficient querying
}
]
// indexes: [
// {
// unique: true,
// fields: ['postId', 'tagId'] // Composite unique index
// },
// {
// fields: ['postId'] // Index for efficient querying
// },
// {
// fields: ['tagId'] // Index for efficient querying
// }
// ]
});
return PostTag;

View File

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