Add RE uploaded Form16 PDF listing and bulk download support in backend, including dependency and migration updates required by the new flow. Made-with: Cursor
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { QueryInterface } from 'sequelize';
|
|
|
|
module.exports = {
|
|
up: async (queryInterface: QueryInterface) => {
|
|
// Speeds latest-submission window ordering per dealer+FY+quarter.
|
|
await queryInterface.sequelize.query(`
|
|
CREATE INDEX IF NOT EXISTS idx_form16a_submissions_dashboard_latest
|
|
ON form16a_submissions (
|
|
dealer_code,
|
|
financial_year,
|
|
quarter,
|
|
version DESC,
|
|
submitted_date DESC,
|
|
created_at DESC,
|
|
id DESC
|
|
);
|
|
`);
|
|
|
|
// Speeds join between latest submissions and 26AS quarter snapshots.
|
|
await queryInterface.sequelize.query(`
|
|
CREATE INDEX IF NOT EXISTS idx_form16a_submissions_tan_fy_quarter
|
|
ON form16a_submissions (tan_number, financial_year, quarter);
|
|
`);
|
|
|
|
// Speeds normalized active dealer lookup used by dashboard aggregation.
|
|
await queryInterface.sequelize.query(`
|
|
CREATE INDEX IF NOT EXISTS idx_dealers_active_normalized_code_region
|
|
ON dealers (
|
|
(TRIM(COALESCE(NULLIF(sales_code, ''), NULLIF(dlrcode, '')))),
|
|
region
|
|
)
|
|
WHERE is_active = true;
|
|
`);
|
|
},
|
|
|
|
down: async (queryInterface: QueryInterface) => {
|
|
await queryInterface.sequelize.query(`
|
|
DROP INDEX IF EXISTS idx_dealers_active_normalized_code_region;
|
|
`);
|
|
|
|
await queryInterface.sequelize.query(`
|
|
DROP INDEX IF EXISTS idx_form16a_submissions_tan_fy_quarter;
|
|
`);
|
|
|
|
await queryInterface.sequelize.query(`
|
|
DROP INDEX IF EXISTS idx_form16a_submissions_dashboard_latest;
|
|
`);
|
|
},
|
|
};
|
|
|