From 4fe3b2365bad105499ba3864ccca37d4657f0e95 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Fri, 21 Aug 2026 02:27:37 +0200 Subject: [PATCH] =?UTF-8?q?fix(critical):=20automation=20plugin=20User.ten?= =?UTF-8?q?ant=5Fid=20does=20not=20exist=20=E2=80=94=20use=20UserTenant=20?= =?UTF-8?q?join?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User model has no tenant_id column. Users are linked to tenants via UserTenant join table. This bug blocked all plugin activation in prestart.sh. --- app/plugins/builtins/automation/plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/plugins/builtins/automation/plugin.py b/app/plugins/builtins/automation/plugin.py index fc6c33a..afb6e6c 100644 --- a/app/plugins/builtins/automation/plugin.py +++ b/app/plugins/builtins/automation/plugin.py @@ -248,13 +248,16 @@ class AutomationPlugin(BasePlugin): from sqlalchemy import select as sa_select # Get first tenant + admin user for seeding - from app.models.user import User + from app.models.user import User, UserTenant from app.models.tenant import Tenant tenant_result = await db.execute(sa_select(Tenant).limit(1)) tenant = tenant_result.scalar_one_or_none() if tenant: user_result = await db.execute( - sa_select(User).where(User.tenant_id == tenant.id).limit(1) + sa_select(User) + .join(UserTenant, UserTenant.user_id == User.id) + .where(UserTenant.tenant_id == tenant.id) + .limit(1) ) user = user_result.scalar_one_or_none() if user: