Created
November 10, 2022 12:51
-
-
Save sekaiwish/cb8b97d5c4487e67c9ba412b207fa667 to your computer and use it in GitHub Desktop.
Reindex Erupe Guild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do | |
$$ | |
declare guild_to_resort integer := <guild id>; | |
declare f record; | |
declare i integer := 2; | |
declare char_id integer; | |
begin | |
for f in select gc.id | |
from public.guild_characters gc | |
join public.guilds g on g.id = gc.guild_id | |
where gc.guild_id = guild_to_resort | |
and gc.id != g.leader_id | |
loop | |
update public.guild_characters gc | |
set order_index = i | |
where id = f.id; | |
i = i + 1; | |
end loop; | |
update public.guild_characters gc | |
set order_index = 1 | |
where id = (select leader_id from guilds where id = guild_to_resort); | |
end; | |
$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment