Notifications interface (#5354)
Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.sequelize.transaction(async (transaction) => {
|
||||
await queryInterface.addColumn("notifications", "archivedAt", {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
transaction,
|
||||
});
|
||||
await queryInterface.addIndex("notifications", ["archivedAt"], {
|
||||
transaction,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.sequelize.transaction(async (transaction) => {
|
||||
await queryInterface.removeIndex("notifications", ["archivedAt"], {
|
||||
transaction,
|
||||
});
|
||||
await queryInterface.removeColumn("notifications", "archivedAt", {
|
||||
transaction,
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.sequelize.transaction(async (transaction) => {
|
||||
await queryInterface.addIndex("notifications", ["createdAt"], {
|
||||
transaction,
|
||||
});
|
||||
await queryInterface.addIndex("notifications", ["event"], {
|
||||
transaction,
|
||||
});
|
||||
await queryInterface.addIndex("notifications", ["viewedAt"], {
|
||||
where: {
|
||||
viewedAt: {
|
||||
[Sequelize.Op.is]: null,
|
||||
},
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.sequelize.transaction(async (transaction) => {
|
||||
await queryInterface.removeIndex("notifications", ["createdAt"], {
|
||||
transaction,
|
||||
});
|
||||
await queryInterface.removeIndex("notifications", ["event"], {
|
||||
transaction,
|
||||
});
|
||||
await queryInterface.removeIndex("notifications", ["viewedAt"], {
|
||||
transaction,
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user