I apologize if it is a naive question but I am new to sequelize and i am trying to talk to database using QueryInterface.
module.exports = {
up: function (queryInterface, Sequelize) {
queryInterface.addIndex(
'entry',
['create_date', 'username'],
{
indexName: 'create_date_username'
}
);
queryInterface.addIndex(
'entry',
['username'],
{
indexName: 'username'
}
);
queryInterface.addIndex(
'entry',
['source_id', 'source_type'],
{
indexName: 'source_id_source_type'
}
)
.then(() =>
Promise (
????
)
);
},
down: function (queryInterface, Sequelize) {
queryInterface.removeIndex('entry', 'create_date_username');
queryInterface.removeIndex('entry', 'username');
queryInterface.removeIndex('entry', 'source_id_source_type');
}
};
But i am getting an ERROR: Migration 20112-Add-Indices.js (or wrapper) didn't return a promise.
But i am new to it and not sure how to exactly return a promise. Can someone assist me with it please. Thank you.
CodePudding user response:
You forgot the return statement. Try something like this:
up: function (queryInterface, Sequelize) {
return Promise.all([
queryInterface.addIndex(
'entry',
['create_date', 'username'],
{
indexName: 'create_date_username'
}
),
queryInterface.addIndex(
'entry',
['username'],
{
indexName: 'username'
}
),
queryInterface.addIndex(
'entry',
['source_id', 'source_type'],
{
indexName: 'source_id_source_type'
}
)
])
.then(() => ...