yumechi-no-kuni/update.sql
eternal-flame-AD 5125e98699
All checks were successful
Lint / pnpm_install (push) Successful in 1m47s
Lint / lint (backend) (push) Successful in 3m14s
Lint / lint (frontend-embed) (push) Successful in 2m23s
Lint / lint (frontend-shared) (push) Successful in 2m13s
Lint / lint (misskey-bubble-game) (push) Successful in 2m12s
Lint / lint (frontend) (push) Successful in 11m39s
Lint / lint (misskey-js) (push) Successful in 2m29s
Lint / lint (misskey-reversi) (push) Successful in 2m21s
Lint / lint (sw) (push) Successful in 2m23s
Lint / typecheck (backend) (push) Successful in 2m19s
Lint / typecheck (misskey-js) (push) Successful in 1m25s
Lint / typecheck (sw) (push) Successful in 1m19s
update ci lint path
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2024-11-08 09:45:58 -06:00

21 lines
No EOL
1.1 KiB
SQL

CREATE TEMPORARY TABLE "user_avatar_update" (
"id" CHARACTER VARYING(32) PRIMARY KEY NOT NULL,
"updatedAvatarUrl" CHARACTER VARYING(512) NOT NULL
)
CREATE INDEX "user_avatar_update_url" ON "user_avatar_update" ("updatedAvatarUrl")
with typed as (
select *,
case when "avatarUrl" ~ '%2Fproxy%2F' then 'nested'
when "avatarUrl" ~ '^https://mproxy\.mi\.yumechi\.jp' then 'proxied'
when "avatarUrl" ~ '^https://mi\.yumechi\.jp' then 'direct'
else 'unknown' end
AS proxy_type
FROM "user" WHERE "avatarUrl" IS NOT NULL)
INSERT INTO "user_avatar_update" ("id", "updatedAvatarUrl")
SELECT "id", 'https://mproxy.mi.yumechi.jp/' || SUBSTRING("avatarUrl" FROM 1 + LENGTH('https://mi.yumechi.jp/')) AS "updatedAvatarUrl" FROM typed WHERE proxy_type = 'direct'
UPDATE "user" SET "avatarUrl" = "user_avatar_update"."updatedAvatarUrl" FROM "user_avatar_update" WHERE "user"."id" = "user_avatar_update"."id"
SELECT typed."id", "avatarUrl", 'https://mproxy.mi.yumechi.jp/' || SUBSTRING("avatarUrl" FROM 1 + LENGTH('https://mi.yumechi.jp/')) AS aft from typed where proxy_type = 'direct'