Node.js based forum software built for the modern web
fix: closes #14926, create indices when converting objects table (#14928)
Dan Van Atta2cd36780b8fd
diff --git a/src/database/postgres.js b/src/database/postgres.jsindex 34649c2811..9a14fb490f 100644--- a/src/database/postgres.js+++ b/src/database/postgres.js@@ -271,6 +271,7 @@ SELECT "_key", "type"FROM "legacy_object"WHERE "expireAt" IS NULLOR "expireAt" > CURRENT_TIMESTAMP`);+ await createIndices(client);}if (!res.rows[0].c) {@@ -352,8 +353,7 @@ postgresModule.createIndices = async function () {}winston.info('[database] Checking database indices.');try {- await postgresModule.pool.query(`CREATE INDEX IF NOT EXISTS "idx__legacy_zset__key__score" ON "legacy_zset"("_key" ASC, "score" DESC)`);- await postgresModule.pool.query(`CREATE INDEX IF NOT EXISTS "idx__legacy_object__expireAt" ON "legacy_object"("expireAt" ASC)`);+ await createIndices(postgresModule.pool);winston.info('[database] Checking database indices done!');} catch (err) {winston.error(`Error creating index ${err.message}`);@@ -361,6 +361,12 @@ postgresModule.createIndices = async function () {}};+function createIndices(client) {+ return client.query(`+CREATE INDEX IF NOT EXISTS "idx__legacy_zset__key__score" ON "legacy_zset"("_key" ASC, "score" DESC);+CREATE INDEX IF NOT EXISTS "idx__legacy_object__expireAt" ON "legacy_object"("expireAt" ASC);`);+}+postgresModule.checkCompatibility = function (callback) {const postgresPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../node_modules/pg/package.json'), 'utf8'));postgresModule.checkCompatibilityVersion(postgresPkg.version, callback);