#210 Apps: SQL queries file for app operations

closed high Created 2025-12-01 04:17 · Updated 2025-12-01 05:15

Description

Edit
## Parent Epic: #195 ## Description Create SQL queries file for all app database operations per database_rules guideline. ## Location engine/sql/queries/apps.sql ## Queries Required ### App Registry - apps_create: INSERT new app - apps_get_by_id: SELECT by app_id - apps_get_by_name: SELECT by (app_name, publisher_id) - apps_list: SELECT with filters/pagination - apps_update: UPDATE metadata - apps_delete: UPDATE status to 'deleted' - apps_search: Full-text search ### App Versions - app_versions_create: INSERT new version - app_versions_get_by_id: SELECT by version_id - app_versions_list: SELECT by app_id - app_versions_get_latest: SELECT latest published - app_versions_publish: UPDATE status to 'published' - app_versions_deprecate: UPDATE status to 'deprecated' ### Tenant Installations - installations_create: INSERT installation - installations_get: SELECT by (tenant_id, app_id) - installations_list: SELECT by tenant_id - installations_update_config: UPDATE configuration - installations_upgrade: UPDATE version_id - installations_enable: UPDATE status to 'enabled' - installations_disable: UPDATE status to 'disabled' - installations_delete: DELETE installation - installations_update_usage: UPDATE last_used_at, usage_count ### Secrets Config - secrets_set: UPDATE secrets_config (JSONB merge) - secrets_delete: UPDATE secrets_config (JSONB remove) - secrets_list: SELECT keys from secrets_config ### Execution Logs - execution_log_insert: INSERT log entry - execution_log_query: SELECT with filters/pagination ## Query Patterns - Use psycopg.sql.Identifier for dynamic identifiers - Parameterized queries only - RETURNING clause for inserts/updates - Proper index hints where needed ## Testing - All queries tested - SQL injection prevention verified - Performance tested with indexes

Comments

Loading comments...

Context

Loading context...

Audit History

View All
Loading audit history...