de30497f59
- Implemented tenant and user management features including: - Tenant creation and management with associated migrations. - User creation and management with associated migrations. - Tenant membership management with associated migrations. - Platform user roles management with associated migrations. - Quota management with associated migrations. - Article and template management with associated migrations. - Added HTTP handlers for templates and workspaces. - Created tests for protected and public routes. - Introduced a script to check tenant scope in SQL queries. - Documented task plan for backend completion and frontend foundation.
23 lines
929 B
SQL
23 lines
929 B
SQL
-- name: ListTemplates :many
|
|
SELECT id, scope, tenant_id, origin_type, template_key, template_name,
|
|
schema_json, prompt_template, prompt_visibility, card_config_json,
|
|
status, version_no, created_at, updated_at
|
|
FROM article_templates
|
|
WHERE (scope = 'platform' OR tenant_id = sqlc.arg(tenant_id)::bigint)
|
|
AND status = 'active' AND deleted_at IS NULL
|
|
ORDER BY created_at DESC;
|
|
|
|
-- name: GetTemplateByID :one
|
|
SELECT id, scope, tenant_id, origin_type, template_key, template_name,
|
|
schema_json, prompt_template, prompt_visibility, protected_prompt_asset_key,
|
|
card_config_json, status, version_no, created_at, updated_at
|
|
FROM article_templates
|
|
WHERE id = sqlc.arg(id)
|
|
AND (scope = 'platform' OR tenant_id = sqlc.arg(tenant_id)::bigint)
|
|
AND deleted_at IS NULL;
|
|
|
|
-- name: GetTemplateSchema :one
|
|
SELECT id, template_name, schema_json
|
|
FROM article_templates
|
|
WHERE id = sqlc.arg(id) AND deleted_at IS NULL;
|