add indexes
This commit is contained in:
parent
4c2a01e5cb
commit
c68aaae044
5 changed files with 57 additions and 0 deletions
|
|
@ -51,6 +51,7 @@
|
|||
"import/prefer-default-export": "off",
|
||||
"import/no-cycle": "off"
|
||||
},
|
||||
"ignorePatterns": ["migrations/**/*.cjs"],
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"node": {
|
||||
|
|
|
|||
25
migrations/20260314153308-add-orders-indexes.cjs
Normal file
25
migrations/20260314153308-add-orders-indexes.cjs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.addIndex('Orders', ['pair_id', 'type', 'status', 'price'], {
|
||||
name: 'orders_pair_id_type_status_price',
|
||||
});
|
||||
await queryInterface.addIndex('Orders', ['pair_id'], {
|
||||
name: 'orders_pair_id',
|
||||
});
|
||||
await queryInterface.addIndex('Orders', ['user_id'], {
|
||||
name: 'orders_user_id',
|
||||
});
|
||||
await queryInterface.addIndex('Orders', ['timestamp'], {
|
||||
name: 'orders_timestamp',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeIndex('Orders', 'orders_pair_id_type_status_price');
|
||||
await queryInterface.removeIndex('Orders', 'orders_pair_id');
|
||||
await queryInterface.removeIndex('Orders', 'orders_user_id');
|
||||
await queryInterface.removeIndex('Orders', 'orders_timestamp');
|
||||
},
|
||||
};
|
||||
20
migrations/20260314153309-add-transactions-indexes.cjs
Normal file
20
migrations/20260314153309-add-transactions-indexes.cjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.addIndex('Transactions', ['buy_order_id', 'status'], {
|
||||
name: 'transactions_buy_order_id_status',
|
||||
});
|
||||
await queryInterface.addIndex('Transactions', ['sell_order_id', 'status'], {
|
||||
name: 'transactions_sell_order_id_status',
|
||||
});
|
||||
await queryInterface.addIndex('Transactions', ['timestamp'], {
|
||||
name: 'transactions_timestamp',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeIndex('Transactions', 'transactions_buy_order_id_status');
|
||||
await queryInterface.removeIndex('Transactions', 'transactions_sell_order_id_status');
|
||||
await queryInterface.removeIndex('Transactions', 'transactions_timestamp');
|
||||
},
|
||||
};
|
||||
|
|
@ -101,6 +101,12 @@ Order.init(
|
|||
sequelize,
|
||||
modelName: 'Order',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['pair_id', 'type', 'status', 'price'] },
|
||||
{ fields: ['pair_id'] },
|
||||
{ fields: ['user_id'] },
|
||||
{ fields: ['timestamp'] },
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ Transaction.init(
|
|||
sequelize,
|
||||
modelName: 'Transaction',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['buy_order_id', 'status'] },
|
||||
{ fields: ['sell_order_id', 'status'] },
|
||||
{ fields: ['timestamp'] },
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue