mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
only drop indexes if they exist
This commit is contained in:
parent
ce57df3bce
commit
bfca086e7b
@ -8,10 +8,19 @@ export async function up(next) {
|
|||||||
const transaction = session.beginTransaction()
|
const transaction = session.beginTransaction()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Drop all indexes because due to legacy code they might be set already
|
// Drop indexes if they exist because due to legacy code they might be set already
|
||||||
|
const indexesResponse = await transaction.run(`CALL db.indexes()`)
|
||||||
|
const indexes = indexesResponse.records.map((record) => record.get('indexName'))
|
||||||
|
console.log(indexes)
|
||||||
|
if(indexes.indexOf('user_fulltext_search') > -1){
|
||||||
await transaction.run(`CALL db.index.fulltext.drop("user_fulltext_search")`)
|
await transaction.run(`CALL db.index.fulltext.drop("user_fulltext_search")`)
|
||||||
|
}
|
||||||
|
if(indexes.indexOf('post_fulltext_search') > -1){
|
||||||
await transaction.run(`CALL db.index.fulltext.drop("post_fulltext_search")`)
|
await transaction.run(`CALL db.index.fulltext.drop("post_fulltext_search")`)
|
||||||
|
}
|
||||||
|
if(indexes.indexOf('tag_fulltext_search') > -1){
|
||||||
await transaction.run(`CALL db.index.fulltext.drop("tag_fulltext_search")`)
|
await transaction.run(`CALL db.index.fulltext.drop("tag_fulltext_search")`)
|
||||||
|
}
|
||||||
// Create indexes
|
// Create indexes
|
||||||
await transaction.run(
|
await transaction.run(
|
||||||
`CALL db.index.fulltext.createNodeIndex("user_fulltext_search",["User"],["name", "slug"])`,
|
`CALL db.index.fulltext.createNodeIndex("user_fulltext_search",["User"],["name", "slug"])`,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user