Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Drop indexes

g.sys.system.dropIndexes calls the drop indexes system API from your code, whatever the settings of that API say about HTTP callers.

Drop indexes System API

Drop indexes of a table by name using global object 'g'. A name the table does not have is NOT_FOUND, not an error, so the call can run again.

const results = await g.sys.system.dropIndexes({
    instance: 'mysql8',
    database: 'inventory',
    table: 'orders',
    indexes: ['am_ix_orders_customer_id_status_3f9a1c', 'old_idx_status'],
    ifExists: true,         // default : a missing index is NOT_FOUND
    continueOnError: true,  // default : one refused drop does not stop the others
});
// results[0] : { status: 'DROPPED', fields: ['customer_id', 'status'], ... }
// results[1] : { status: 'NOT_FOUND', message: 'The index "old_idx_status" does not exist.', ... }
  • Several tables at once : give a list of such objects, the results come back in one flat list.
  • instance: "crm::acme" drops in the database of the tenant acme of the multi-tenant instance crm.