Fixed bad migration
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
-- Room backgrounds: PNG assets in /public/room with ids room-1 .. room-4.
|
-- Room backgrounds: PNG assets in /public/room with ids room-1 .. room-4.
|
||||||
|
-- Drop legacy check before rewriting values (old ids: room-day, room-dusk, etc.).
|
||||||
|
alter table
|
||||||
|
public.avatar_state drop constraint if exists avatar_state_room_background_check;
|
||||||
|
|
||||||
alter table public.avatar_state
|
update
|
||||||
alter column room_background set default 'room-1';
|
public.avatar_state
|
||||||
|
set
|
||||||
update public.avatar_state
|
room_background = case
|
||||||
set room_background = case room_background
|
room_background
|
||||||
when 'room-day' then 'room-1'
|
when 'room-day' then 'room-1'
|
||||||
when 'room-dusk' then 'room-2'
|
when 'room-dusk' then 'room-2'
|
||||||
when 'room-night' then 'room-3'
|
when 'room-night' then 'room-3'
|
||||||
@@ -13,7 +16,8 @@ set room_background = case room_background
|
|||||||
when 'room-neon' then 'room-1'
|
when 'room-neon' then 'room-1'
|
||||||
else room_background
|
else room_background
|
||||||
end
|
end
|
||||||
where room_background in (
|
where
|
||||||
|
room_background in (
|
||||||
'room-day',
|
'room-day',
|
||||||
'room-dusk',
|
'room-dusk',
|
||||||
'room-night',
|
'room-night',
|
||||||
@@ -22,34 +26,26 @@ where room_background in (
|
|||||||
'room-neon'
|
'room-neon'
|
||||||
);
|
);
|
||||||
|
|
||||||
update public.user_items
|
-- Rows already on new ids or unknown values: coerce to a valid default.
|
||||||
set item_id = case item_id
|
update
|
||||||
when 'room-night' then 'room-3'
|
public.avatar_state
|
||||||
when 'room-forest' then 'room-4'
|
|
||||||
else item_id
|
|
||||||
end
|
|
||||||
where item_id in ('room-night', 'room-forest');
|
|
||||||
|
|
||||||
delete from public.shop_items
|
|
||||||
where id in ('room-night', 'room-forest');
|
|
||||||
|
|
||||||
insert into public.shop_items (id, name, type, price, image_path)
|
|
||||||
values
|
|
||||||
('room-3', 'Starlit Night', 'room', 40, '/room/room-3.png'),
|
|
||||||
('room-4', 'Mystic Forest', 'room', 50, '/room/room-4.png')
|
|
||||||
on conflict (id) do update
|
|
||||||
set
|
set
|
||||||
name = excluded.name,
|
room_background = 'room-1'
|
||||||
type = excluded.type,
|
where
|
||||||
price = excluded.price,
|
room_background is null
|
||||||
image_path = excluded.image_path;
|
or room_background not in ('room-1', 'room-2', 'room-3', 'room-4');
|
||||||
|
|
||||||
alter table public.avatar_state
|
alter table
|
||||||
drop constraint if exists avatar_state_room_background_check;
|
public.avatar_state
|
||||||
|
alter column
|
||||||
|
room_background
|
||||||
|
set
|
||||||
|
default 'room-1';
|
||||||
|
|
||||||
alter table public.avatar_state
|
alter table
|
||||||
add constraint avatar_state_room_background_check
|
public.avatar_state
|
||||||
check (
|
add
|
||||||
|
constraint avatar_state_room_background_check check (
|
||||||
room_background in (
|
room_background in (
|
||||||
'room-1',
|
'room-1',
|
||||||
'room-2',
|
'room-2',
|
||||||
@@ -57,3 +53,44 @@ alter table public.avatar_state
|
|||||||
'room-4'
|
'room-4'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
update
|
||||||
|
public.user_items
|
||||||
|
set
|
||||||
|
item_id = case
|
||||||
|
item_id
|
||||||
|
when 'room-night' then 'room-3'
|
||||||
|
when 'room-forest' then 'room-4'
|
||||||
|
else item_id
|
||||||
|
end
|
||||||
|
where
|
||||||
|
item_id in ('room-night', 'room-forest');
|
||||||
|
|
||||||
|
delete from
|
||||||
|
public.shop_items
|
||||||
|
where
|
||||||
|
id in ('room-night', 'room-forest');
|
||||||
|
|
||||||
|
insert into
|
||||||
|
public.shop_items (id, name, type, price, image_path)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
'room-3',
|
||||||
|
'Starlit Night',
|
||||||
|
'room',
|
||||||
|
40,
|
||||||
|
'/room/room-3.png'
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'room-4',
|
||||||
|
'Mystic Forest',
|
||||||
|
'room',
|
||||||
|
50,
|
||||||
|
'/room/room-4.png'
|
||||||
|
) on conflict (id) do
|
||||||
|
update
|
||||||
|
set
|
||||||
|
name = excluded.name,
|
||||||
|
type = excluded.type,
|
||||||
|
price = excluded.price,
|
||||||
|
image_path = excluded.image_path;
|
||||||
Reference in New Issue
Block a user