mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-08-22 08:34:13 -05:00
Some checks failed
Deploy Supabase Migrations to Production / migrate (push) Has been cancelled
* Add `hack_patcher_patches` table * Implement patcher version server actions * Use first curated patch as default when custom patcher list is active * Allow saving custom patcher lists with unpublished patch auto-publish * Keep custom patcher list consistent across archive and new uploads * Add creator UI for Latest vs Custom patcher version settings * Add patch version picker to hack page downloader * Add custom public version names for Custom patcher mode * Fix direct patch download consistency between Latest vs Custom modes * Consolidate download and patch to one button press * Fix rom ready for patching checks * Fix Select ROM pop-in while base roms loading * Tighten patcher patches db insertion * Harden getSignedPatchUrl permission checks * Fix not using selected patch's filename * Acknowledge Custom patcher setting in HackPatchForm * Update types/db.ts * Refresh discover cache on patch published * Add migration ordering check to ci.yaml * Fix new migrations ordering
55 lines
1.8 KiB
PL/PgSQL
55 lines
1.8 KiB
PL/PgSQL
create or replace function public.replace_hack_patcher_patches(
|
|
p_hack_slug text,
|
|
p_patch_ids bigint[],
|
|
p_custom_version_name text default null
|
|
)
|
|
returns void
|
|
language plpgsql
|
|
security invoker
|
|
set search_path = public
|
|
as $$
|
|
declare
|
|
v_count integer;
|
|
begin
|
|
-- Empty list = switch to Latest mode
|
|
if coalesce(cardinality(p_patch_ids), 0) = 0 then
|
|
delete from public.hack_patcher_patches where hack_slug = p_hack_slug;
|
|
update public.hacks set custom_version_name = null where slug = p_hack_slug;
|
|
return;
|
|
end if;
|
|
|
|
if p_custom_version_name is null or length(btrim(p_custom_version_name)) = 0 then
|
|
raise exception 'Custom version name is required';
|
|
end if;
|
|
if length(btrim(p_custom_version_name)) > 12 then
|
|
raise exception 'Custom version name must 12 characters or less';
|
|
end if;
|
|
|
|
-- All IDs must belong to the same hack
|
|
select count(*) into v_count
|
|
from public.patches p
|
|
where p.id = any(p_patch_ids)
|
|
and p.parent_hack = p_hack_slug
|
|
and p.archived = false;
|
|
|
|
if v_count <> cardinality(p_patch_ids) then
|
|
raise exception 'One or more patches either do not belong to this hack or are archived';
|
|
end if;
|
|
|
|
delete from public.hack_patcher_patches where hack_slug = p_hack_slug;
|
|
insert into public.hack_patcher_patches (hack_slug, patch_id, sort_order)
|
|
select
|
|
p_hack_slug,
|
|
patch_id,
|
|
ordinality::integer
|
|
from unnest(p_patch_ids) with ordinality as t(patch_id, ordinality);
|
|
update public.hacks
|
|
set custom_version_name = btrim(p_custom_version_name)
|
|
where slug = p_hack_slug;
|
|
end;
|
|
$$;
|
|
|
|
revoke all on function public.replace_hack_patcher_patches(text, bigint[], text) from public;
|
|
grant execute on function public.replace_hack_patcher_patches(text, bigint[], text) to authenticated;
|
|
grant execute on function public.replace_hack_patcher_patches(text, bigint[], text) to service_role;
|