import { P_DROP_INDEX } from '../../../../../typings' ; import { DatabaseModelInterface , TableModelInterface , RuleHandler } from '../typings' ; /**
 * Formatter for P_DROP_INDEX rule's parsed JSON.
 */ export class DropIndex implements RuleHandler { database ! : DatabaseModelInterface ; param name getTable ( name ) { return this . database . getTable ( name ) ; } param database setDatabase ( database ) { this . database = database ; } param json handleDef ( json ) { if ( json . id === 'P_DROP_INDEX' ) { const table = this . getTable ( json . def . table ) ; if ( ! table ) { return ; } const index = table . getIndexByName ( json . def . index ) ; if ( ! index ) { return ; } table . dropIndexByInstance ( index ) ; return ; } throw new TypeError ( `Expected P_DROP_INDEX rule to be handled but received ${ json . id }` ) ; } }