parent
12eadb80ae
commit
cc40d15082
|
@ -391,12 +391,13 @@ MySQL.prototype.alterTable = function (model, actualFields, actualIndexes, done,
|
|||
// remove indexes
|
||||
aiNames.forEach(function (indexName) {
|
||||
if (indexName === 'id' || indexName === 'PRIMARY') return;
|
||||
if (indexNames.indexOf(indexName) === -1 || m.properties[indexName] && !m.properties[indexName].index) {
|
||||
if (indexNames.indexOf(indexName) === -1 && !m.properties[indexName] || m.properties[indexName] && !m.properties[indexName].index) {
|
||||
sql.push('DROP INDEX `' + indexName + '`');
|
||||
} else {
|
||||
// first: check single (only type and kind)
|
||||
if (m.properties[indexName] && !m.properties[indexName].index) {
|
||||
// TODO
|
||||
return;
|
||||
}
|
||||
// second: check multiple indexes
|
||||
var orderMatched = true;
|
||||
|
|
|
@ -168,7 +168,7 @@ it 'should add single-column index', (test) ->
|
|||
it 'should change type of single-column index', (test) ->
|
||||
User.defineProperty 'email', type: String, index: { type: 'BTREE' }
|
||||
User.schema.isActual (err, ok) ->
|
||||
test.ok not ok, 'schema is not actual'
|
||||
test.ok ok, 'schema is actual'
|
||||
User.schema.autoupdate (err) ->
|
||||
return console.log(err) if err
|
||||
getIndexes 'User', (err, ixs) ->
|
||||
|
@ -195,6 +195,14 @@ it 'should update multi-column index when order of columns changed', (test) ->
|
|||
test.equals ixs.index1.Column_name, 'createdByAdmin'
|
||||
test.done()
|
||||
|
||||
|
||||
it 'test', (test) ->
|
||||
User.defineProperty 'email', type: String, index: true
|
||||
User.schema.autoupdate (err) ->
|
||||
User.schema.autoupdate (err) ->
|
||||
User.schema.autoupdate (err) ->
|
||||
test.done()
|
||||
|
||||
it 'should disconnect when done', (test) ->
|
||||
schema.disconnect()
|
||||
test.done()
|
||||
|
|
Loading…
Reference in New Issue