yumechi-no-kuni/yume-mods/admin-scripts/sql/update.sql
eternal-flame-AD 1862b33aba
All checks were successful
Lint / pnpm_install (push) Successful in 2m23s
Publish Docker image / Build (push) Successful in 5m4s
Lint / lint (backend) (push) Successful in 2m29s
Test (backend) / unit (22.11.0) (push) Successful in 9m49s
Lint / lint (frontend) (push) Successful in 2m35s
Lint / lint (frontend-embed) (push) Successful in 2m24s
Lint / lint (frontend-shared) (push) Successful in 2m40s
Lint / lint (misskey-bubble-game) (push) Successful in 2m29s
Lint / lint (misskey-js) (push) Successful in 2m41s
Test (backend) / e2e (22.11.0) (push) Successful in 13m29s
Lint / lint (misskey-reversi) (push) Successful in 2m51s
Lint / typecheck (backend) (push) Successful in 3m4s
Lint / lint (sw) (push) Successful in 3m10s
Lint / typecheck (misskey-js) (push) Successful in 1m46s
Test (production install and build) / production (22.11.0) (push) Successful in 1m24s
Lint / typecheck (sw) (push) Successful in 1m46s
pgroonga CW search
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2024-11-16 05:50:57 -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'