forked from FoundKeyGang/FoundKey
Johann150
7a981de883
The column mentionedRemoteUsers on the note table in the database is firstly in the wrong type since it contains JSON data but is typed as text. Secondly it seems redundant, since that data can be acquired by using the note.mentions column to fetch the respective data instead. Co-authored-by: Francis Dinh <normandy@biribiri.dev>
12 lines
711 B
JavaScript
12 lines
711 B
JavaScript
export class removeMentionedRemoteUsersColumn1661376843000 {
|
|
name = 'removeMentionedRemoteUsersColumn1661376843000';
|
|
|
|
async up(queryRunner) {
|
|
await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "mentionedRemoteUsers"`);
|
|
}
|
|
|
|
async down(queryRunner) {
|
|
await queryRunner.query(`ALTER TABLE "note" ADD "mentionedRemoteUsers" TEXT NOT NULL DEFAULT '[]'::text`);
|
|
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")`);
|
|
}
|
|
}
|