37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
/**
|
|
* Form 16 / 26AS data retention: add archived_at to keep last 5 FY active.
|
|
* Records with financial_year older than 5 years get archived_at set by scheduler (no deletion).
|
|
*/
|
|
|
|
import { QueryInterface, DataTypes } from 'sequelize';
|
|
|
|
const TABLES_WITH_FY = [
|
|
'tds_26as_entries',
|
|
'form_16_26as_quarter_snapshots',
|
|
'form_16_quarter_status',
|
|
'form_16_ledger_entries',
|
|
'form_16_credit_notes',
|
|
'form16a_submissions',
|
|
] as const;
|
|
|
|
export async function up(queryInterface: QueryInterface): Promise<void> {
|
|
for (const table of TABLES_WITH_FY) {
|
|
await queryInterface.addColumn(table, 'archived_at', {
|
|
type: DataTypes.DATE,
|
|
allowNull: true,
|
|
comment: 'Set when record is older than 5 financial years; active when NULL',
|
|
});
|
|
}
|
|
await queryInterface.addColumn('form_16_debit_notes', 'archived_at', {
|
|
type: DataTypes.DATE,
|
|
allowNull: true,
|
|
comment: 'Set when linked credit_note is archived; active when NULL',
|
|
});
|
|
}
|
|
|
|
export async function down(queryInterface: QueryInterface): Promise<void> {
|
|
for (const table of [...TABLES_WITH_FY, 'form_16_debit_notes']) {
|
|
await queryInterface.removeColumn(table, 'archived_at');
|
|
}
|
|
}
|