Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/upgrade/upgrade_scripts/5.21.0/remove_datachunks_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright (C) 2025 NooBaa */
"use strict";

/**
* Drop the database index named "idx_btree_datachunks_dedup_key" if it exists.
*
* Executes the DROP INDEX operation against the connected database, logs success,
* and rethrows any error after logging it.
*
* @param {{dbg: object, db_client: object}} args - Utilities required to perform the upgrade: a logger (`dbg`) and a database client (`db_client`).
* @throws {Error} Re-throws any error encountered while executing the DROP INDEX statement.
*/
async function run({ dbg, db_client }) {
const indexName = 'idx_btree_datachunks_dedup_key';

try {
const pool = db_client.instance().get_pool();
await pool.query(`DROP INDEX IF EXISTS ${indexName};`);

dbg.log2("Executed upgrade script for dropping index ", indexName);
} catch (err) {
dbg.error('An error ocurred in the upgrade process:', err);
throw err;
}
}

module.exports = {
run,
description: 'Delete the "idx_btree_datachunks_dedup_key" index'
};
Loading