lib/adapters/mysql.js
function (table, opts) {
            var indexes = {};
            var removeIndexes = [];
            var m = this.outputIdentifierFunc;
            var im = this.inputIdentifierFunc;
            return this.metadataDataset.withSql("SHOW INDEX FROM ?", isInstanceOf(table, sql.Identifier) ? table : sql.identifier(im(table)))
                .forEach(function (r) {
                    var name = r[m("Key_name")];
                    if (name !== "PRIMARY") {
                        name = m(name);
                        if (r[m("Sub_part")]) {
                            removeIndexes.push(name);
                        }
                        var i = indexes[name] || (indexes[name] = {columns: [], unique: r[m("Non_unique")] !== 1});
                        i.columns.push(m(r[m("Column_name")]));
                    }
                }).chain(function () {
                    var r = {};
                    for (var i in indexes) {
                        if (removeIndexes.indexOf(i) === -1) {
                            r[i] = indexes[i];
                        }
                    }
                    return r;
                });

        }
function (table, opts) {
            var indexes = {};
            var removeIndexes = [];
            var m = this.outputIdentifierFunc;
            var im = this.inputIdentifierFunc;
            return this.metadataDataset.withSql("SHOW INDEX FROM ?", isInstanceOf(table, sql.Identifier) ? table : sql.identifier(im(table)))
                .forEach(function (r) {
                    var name = r[m("Key_name")];
                    if (name !== "PRIMARY") {
                        name = m(name);
                        if (r[m("Sub_part")]) {
                            removeIndexes.push(name);
                        }
                        var i = indexes[name] || (indexes[name] = {columns: [], unique: r[m("Non_unique")] !== 1});
                        i.columns.push(m(r[m("Column_name")]));
                    }
                }).chain(function () {
                    var r = {};
                    for (var i in indexes) {
                        if (removeIndexes.indexOf(i) === -1) {
                            r[i] = indexes[i];
                        }
                    }
                    return r;
                });

        }
function ( table , opts ) { var indexes = { } ; var removeIndexes = [ ] ; var m = this . outputIdentifierFunc ; var im = this . inputIdentifierFunc ; return this . metadataDataset . withSql ( "SHOW INDEX FROM ?" , isInstanceOf ( table , sql . Identifier ) ? table : sql . identifier ( im ( table ) ) ) . forEach ( function ( r ) { var name = r [ m ( "Key_name" ) ] ; if ( name !== "PRIMARY" ) { name = m ( name ) ; if ( r [ m ( "Sub_part" ) ] ) { removeIndexes . push ( name ) ; } var i = indexes [ name ] || ( indexes [ name ] = { columns : [ ] , unique : r [ m ( "Non_unique" ) ] !== 1 } ) ; i . columns . push ( m ( r [ m ( "Column_name" ) ] ) ) ; } } ) . chain ( function ( ) { var r = { } ; for ( var i in indexes ) { if ( removeIndexes . indexOf ( i ) === - 1 ) { r [ i ] = indexes [ i ] ; } } return r ; } ) ; }
Use SHOW INDEX FROM to get the index information for the table.
Use SHOW INDEX FROM to get the index information for the table .