lib/adapters/mysql.js
function (table, op) {
            var ret = new Promise(), self = this;
            if (op.op === "addColumn") {
                var related = op.table;
                if (related) {
                    delete op.table;
                    ret = this._super(arguments).chain(function (sql) {
                        op.table = related;
                        return [sql, format("ALTER TABLE %s ADD FOREIGN KEY (%s)%s",
                            self.__quoteSchemaTable(table), self.__quoteIdentifier(op.name),
                            self.__columnReferencesSql(op))];
                    });
                } else {
                    ret = this._super(arguments);
                }
            } else if (['renameColumn', "setColumnType", "setColumnNull", "setColumnDefault"].indexOf(op.op) !== -1) {
                ret = this.schema(table).chain(function (schema) {
                    var name = op.name;
                    var opts = schema[Object.keys(schema).filter(function (i) {
                        return i === name;
                    })[0]];
                    opts = merge({}, opts || {});
                    opts.name = op.newName || name;
                    opts.type = op.type || opts.dbType;
                    opts.allowNull = isUndefined(op["null"]) ? opts.allowNull : op["null"];
                    opts["default"] = op["default"] || opts.jsDefault;
                    if (isUndefinedOrNull(opts["default"])) {
                        delete opts["default"];
                    }
                    return format("ALTER TABLE %s CHANGE COLUMN %s %s", self.__quoteSchemaTable(table),
                        self.__quoteIdentifier(op.name), self.__columnDefinitionSql(merge(op, opts)));
                });
            } else if (op.op === "dropIndex") {
                ret = when(format("%s ON %s", this.__dropIndexSql(table, op), this.__quoteSchemaTable(table)));
            } else {
                ret = this._super(arguments);
            }
            return ret.promise();
        }
function (table, op) {
            var ret = new Promise(), self = this;
            if (op.op === "addColumn") {
                var related = op.table;
                if (related) {
                    delete op.table;
                    ret = this._super(arguments).chain(function (sql) {
                        op.table = related;
                        return [sql, format("ALTER TABLE %s ADD FOREIGN KEY (%s)%s",
                            self.__quoteSchemaTable(table), self.__quoteIdentifier(op.name),
                            self.__columnReferencesSql(op))];
                    });
                } else {
                    ret = this._super(arguments);
                }
            } else if (['renameColumn', "setColumnType", "setColumnNull", "setColumnDefault"].indexOf(op.op) !== -1) {
                ret = this.schema(table).chain(function (schema) {
                    var name = op.name;
                    var opts = schema[Object.keys(schema).filter(function (i) {
                        return i === name;
                    })[0]];
                    opts = merge({}, opts || {});
                    opts.name = op.newName || name;
                    opts.type = op.type || opts.dbType;
                    opts.allowNull = isUndefined(op["null"]) ? opts.allowNull : op["null"];
                    opts["default"] = op["default"] || opts.jsDefault;
                    if (isUndefinedOrNull(opts["default"])) {
                        delete opts["default"];
                    }
                    return format("ALTER TABLE %s CHANGE COLUMN %s %s", self.__quoteSchemaTable(table),
                        self.__quoteIdentifier(op.name), self.__columnDefinitionSql(merge(op, opts)));
                });
            } else if (op.op === "dropIndex") {
                ret = when(format("%s ON %s", this.__dropIndexSql(table, op), this.__quoteSchemaTable(table)));
            } else {
                ret = this._super(arguments);
            }
            return ret.promise();
        }
function ( table , op ) { var ret = new Promise ( ) , self = this ; if ( op . op === "addColumn" ) { var related = op . table ; if ( related ) { delete op . table ; ret = this . _super ( arguments ) . chain ( function ( sql ) { op . table = related ; return [ sql , format ( "ALTER TABLE %s ADD FOREIGN KEY (%s)%s" , self . __quoteSchemaTable ( table ) , self . __quoteIdentifier ( op . name ) , self . __columnReferencesSql ( op ) ) ] ; } ) ; } else { ret = this . _super ( arguments ) ; } } else if ( [ 'renameColumn' , "setColumnType" , "setColumnNull" , "setColumnDefault" ] . indexOf ( op . op ) !== - 1 ) { ret = this . schema ( table ) . chain ( function ( schema ) { var name = op . name ; var opts = schema [ Object . keys ( schema ) . filter ( function ( i ) { return i === name ; } ) [ 0 ] ] ; opts = merge ( { } , opts || { } ) ; opts . name = op . newName || name ; opts . type = op . type || opts . dbType ; opts . allowNull = isUndefined ( op [ "null" ] ) ? opts . allowNull : op [ "null" ] ; opts [ "default" ] = op [ "default" ] || opts . jsDefault ; if ( isUndefinedOrNull ( opts [ "default" ] ) ) { delete opts [ "default" ] ; } return format ( "ALTER TABLE %s CHANGE COLUMN %s %s" , self . __quoteSchemaTable ( table ) , self . __quoteIdentifier ( op . name ) , self . __columnDefinitionSql ( merge ( op , opts ) ) ) ; } ) ; } else if ( op . op === "dropIndex" ) { ret = when ( format ( "%s ON %s" , this . __dropIndexSql ( table , op ) , this . __quoteSchemaTable ( table ) ) ) ; } else { ret = this . _super ( arguments ) ; } return ret . promise ( ) ; }
Use MySQL specific syntax for rename column, set column type, and drop index cases.
Use MySQL specific syntax for rename column set column type and drop index cases .