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