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

@ -60,7 +60,7 @@ pub async fn get_scene_by_id<'e>(
s.updated_at,
c.id as default_channel_id
FROM realm.scenes s
LEFT JOIN realm.channels c ON c.scene_id = s.id AND c.channel_type = 'public'
LEFT JOIN scene.instances c ON c.scene_id = s.id AND c.instance_type = 'public'
WHERE s.id = $1
"#,
)
@ -98,7 +98,7 @@ pub async fn get_scene_by_slug<'e>(
s.updated_at,
c.id as default_channel_id
FROM realm.scenes s
LEFT JOIN realm.channels c ON c.scene_id = s.id AND c.channel_type = 'public'
LEFT JOIN scene.instances c ON c.scene_id = s.id AND c.instance_type = 'public'
WHERE s.realm_id = $1 AND s.slug = $2
"#,
)
@ -316,7 +316,7 @@ pub async fn update_scene<'e>(
s.ambient_audio_id, s.ambient_volume, s.sort_order, s.is_entry_point,
s.is_hidden, s.created_at, s.updated_at, c.id as default_channel_id
FROM realm.scenes s
LEFT JOIN realm.channels c ON c.scene_id = s.id AND c.channel_type = 'public'
LEFT JOIN scene.instances c ON c.scene_id = s.id AND c.instance_type = 'public'
WHERE s.id = $1"#.to_string()
} else {
set_clauses.push("updated_at = now()".to_string());
@ -331,7 +331,7 @@ pub async fn update_scene<'e>(
)
SELECT u.*, c.id as default_channel_id
FROM updated u
LEFT JOIN realm.channels c ON c.scene_id = u.id AND c.channel_type = 'public'"#,
LEFT JOIN scene.instances c ON c.scene_id = u.id AND c.instance_type = 'public'"#,
set_clauses.join(", ")
)
};
@ -442,7 +442,7 @@ pub async fn get_entry_scene_for_realm<'e>(
s.updated_at,
c.id as default_channel_id
FROM realm.scenes s
LEFT JOIN realm.channels c ON c.scene_id = s.id AND c.channel_type = 'public'
LEFT JOIN scene.instances c ON c.scene_id = s.id AND c.instance_type = 'public'
WHERE s.realm_id = $1 AND s.is_hidden = false
ORDER BY
CASE WHEN s.id = $2 THEN 0 ELSE 1 END,