move live source ownership to accounts

This commit is contained in:
2026-07-18 22:24:00 -07:00
parent 1598d3c403
commit 53ae90ec13
20 changed files with 219 additions and 124 deletions
+9 -4
View File
@@ -108,8 +108,11 @@ impl Db {
Self::set_tenant(&transaction, user_id).await?;
let rows = transaction
.query(
"SELECT id,source_id,kind,name,settings,settings_version,enabled \
FROM component_instances WHERE owner_user_id=$1 ORDER BY created_at",
"SELECT component.id,source.id,component.kind,component.name,component.settings,\
component.settings_version,component.enabled \
FROM component_instances AS component \
JOIN live_sources AS source ON source.owner_user_id=component.owner_user_id \
WHERE component.owner_user_id=$1 ORDER BY component.created_at",
&[&user_id],
)
.await?;
@@ -119,7 +122,7 @@ impl Db {
.map(|row| ComponentRecord {
id: row.get(0),
owner_user_id: user_id,
source_id: row.get(1),
account_source_id: row.get(1),
kind: row.get(2),
name: row.get(3),
settings: row.get(4),
@@ -141,7 +144,9 @@ pub struct ActiveTenant {
pub struct ComponentRecord {
pub id: Uuid,
pub owner_user_id: Uuid,
pub source_id: Uuid,
/// Derived from the account's singleton live source; it is not component
/// configuration and is never persisted on `component_instances`.
pub account_source_id: Uuid,
pub kind: String,
pub name: String,
pub settings: Value,