clean up index on table deletion
This commit is contained in:
parent
e599854b14
commit
fb4b371d27
|
@ -89,22 +89,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChangePrimaryIndex(e) {
|
function onChangePrimaryIndex(e) {
|
||||||
const enabled = e.target.checked
|
indexes = e.target.checked ? [field.name] : []
|
||||||
if (enabled) {
|
|
||||||
indexes[0] = field.name
|
|
||||||
} else {
|
|
||||||
indexes.shift()
|
|
||||||
indexes = indexes
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChangeSecondaryIndex(e) {
|
function onChangeSecondaryIndex(e) {
|
||||||
const enabled = e.target.checked
|
if (e.target.checked) {
|
||||||
if (enabled) {
|
|
||||||
indexes[1] = field.name
|
indexes[1] = field.name
|
||||||
} else {
|
} else {
|
||||||
indexes.pop()
|
indexes = indexes.slice(0, 1)
|
||||||
indexes = indexes
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,15 @@ exports.destroy = async function(ctx) {
|
||||||
// don't remove the table itself until very end
|
// don't remove the table itself until very end
|
||||||
await db.remove(tableToDelete)
|
await db.remove(tableToDelete)
|
||||||
|
|
||||||
|
// remove table search index
|
||||||
|
const currentIndexes = await db.getIndexes()
|
||||||
|
const existingIndex = currentIndexes.indexes.find(
|
||||||
|
existing => existing.name === `search:${ctx.params.tableId}`
|
||||||
|
)
|
||||||
|
if (existingIndex) {
|
||||||
|
await db.deleteIndex(existingIndex)
|
||||||
|
}
|
||||||
|
|
||||||
ctx.eventEmitter &&
|
ctx.eventEmitter &&
|
||||||
ctx.eventEmitter.emitTable(`table:delete`, appId, tableToDelete)
|
ctx.eventEmitter.emitTable(`table:delete`, appId, tableToDelete)
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
|
|
Loading…
Reference in New Issue