database schema adjustments to server/realm/scene

This commit is contained in:
Evan Carroll 2026-01-16 10:57:47 -06:00
parent a102c96bb4
commit 09590edd95
79 changed files with 7100 additions and 100 deletions

View file

@ -17,7 +17,7 @@ pub async fn list_channel_loose_props<'e>(
r#"
SELECT
lp.id,
lp.channel_id,
lp.instance_id as channel_id,
lp.server_prop_id,
lp.realm_prop_id,
ST_X(lp.position) as position_x,
@ -27,10 +27,10 @@ pub async fn list_channel_loose_props<'e>(
lp.created_at,
COALESCE(sp.name, rp.name) as prop_name,
COALESCE(sp.asset_path, rp.asset_path) as prop_asset_path
FROM props.loose_props lp
FROM scene.loose_props lp
LEFT JOIN server.props sp ON lp.server_prop_id = sp.id
LEFT JOIN props.realm_props rp ON lp.realm_prop_id = rp.id
WHERE lp.channel_id = $1
LEFT JOIN realm.props rp ON lp.realm_prop_id = rp.id
WHERE lp.instance_id = $1
AND (lp.expires_at IS NULL OR lp.expires_at > now())
ORDER BY lp.created_at ASC
"#,
@ -61,17 +61,17 @@ pub async fn drop_prop_to_canvas<'e>(
r#"
WITH item_info AS (
SELECT id, is_droppable, server_prop_id, realm_prop_id, prop_name, prop_asset_path
FROM props.inventory
FROM auth.inventory
WHERE id = $1 AND user_id = $2
),
deleted_item AS (
DELETE FROM props.inventory
DELETE FROM auth.inventory
WHERE id = $1 AND user_id = $2 AND is_droppable = true
RETURNING id, server_prop_id, realm_prop_id, prop_name, prop_asset_path
),
inserted_prop AS (
INSERT INTO props.loose_props (
channel_id,
INSERT INTO scene.loose_props (
instance_id,
server_prop_id,
realm_prop_id,
position,
@ -88,7 +88,7 @@ pub async fn drop_prop_to_canvas<'e>(
FROM deleted_item di
RETURNING
id,
channel_id,
instance_id as channel_id,
server_prop_id,
realm_prop_id,
ST_X(position) as position_x,
@ -202,7 +202,7 @@ pub async fn pick_up_loose_prop<'e>(
let item = sqlx::query_as::<_, InventoryItem>(
r#"
WITH deleted_prop AS (
DELETE FROM props.loose_props
DELETE FROM scene.loose_props
WHERE id = $1
AND (expires_at IS NULL OR expires_at > now())
RETURNING id, server_prop_id, realm_prop_id
@ -219,10 +219,10 @@ pub async fn pick_up_loose_prop<'e>(
dp.realm_prop_id
FROM deleted_prop dp
LEFT JOIN server.props sp ON dp.server_prop_id = sp.id
LEFT JOIN props.realm_props rp ON dp.realm_prop_id = rp.id
LEFT JOIN realm.props rp ON dp.realm_prop_id = rp.id
),
inserted_item AS (
INSERT INTO props.inventory (
INSERT INTO auth.inventory (
user_id,
server_prop_id,
realm_prop_id,
@ -243,7 +243,7 @@ pub async fn pick_up_loose_prop<'e>(
si.prop_name,
si.prop_asset_path,
si.layer,
'server_library'::props.prop_origin,
'server_library'::server.prop_origin,
COALESCE(si.is_transferable, true),
COALESCE(si.is_portable, true),
COALESCE(si.is_droppable, true),
@ -260,7 +260,7 @@ pub async fn pick_up_loose_prop<'e>(
ii.is_transferable,
ii.is_portable,
ii.is_droppable,
'server_library'::props.prop_origin as origin,
'server_library'::server.prop_origin as origin,
ii.acquired_at
FROM inserted_item ii
"#,
@ -280,7 +280,7 @@ pub async fn pick_up_loose_prop<'e>(
pub async fn cleanup_expired_props<'e>(executor: impl PgExecutor<'e>) -> Result<u64, AppError> {
let result = sqlx::query(
r#"
DELETE FROM props.loose_props
DELETE FROM scene.loose_props
WHERE expires_at IS NOT NULL AND expires_at <= now()
"#,
)