- await queryRunner.query(`UPDATE "note" SET "mentionedRemoteUsers" = (SELECT COALESCE(json_agg(row_to_json("data"))::text, '[]') FROM (SELECT "url", "uri", "username", "host" FROM "user" JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL AND "user"."id" = ANY("note"."mentions")) AS "data")`);
+ await queryRunner.query(`
+ CREATE TEMP TABLE IF NOT EXISTS "temp_mentions" AS
+ SELECT "id", "url", "uri", "username", "host"
+ FROM "user"
+ JOIN "user_profile" ON "user"."id" = "user_profile"."userId" WHERE "user"."host" IS NOT NULL
+ `);
+
+ await queryRunner.query(`
+ CREATE UNIQUE INDEX "temp_mentions_id" ON "temp_mentions"("id")