27389164b0
- Implemented image folder repository with CRUD operations. - Added image reference repository for managing image references to articles. - Created image repository for handling image assets, including listing, inserting, updating, and deleting images. - Introduced image usage repository to track storage usage and quotas for tenants. - Added SQL queries for image assets, folders, references, and usage. - Developed image handler for HTTP endpoints to manage images and folders. - Created database migration scripts for image-related tables and structures.
16 lines
515 B
SQL
16 lines
515 B
SQL
-- name: EnsureImageStorageUsageRow :exec
|
|
INSERT INTO tenant_image_storage_usage (tenant_id, used_bytes)
|
|
VALUES (sqlc.arg(tenant_id), 0)
|
|
ON CONFLICT (tenant_id) DO NOTHING;
|
|
|
|
-- name: GetImageStorageUsage :one
|
|
SELECT used_bytes, updated_at
|
|
FROM tenant_image_storage_usage
|
|
WHERE tenant_id = sqlc.arg(tenant_id);
|
|
|
|
-- name: ReleaseImageStorageQuota :exec
|
|
UPDATE tenant_image_storage_usage
|
|
SET used_bytes = GREATEST(0, used_bytes - sqlc.arg(release_bytes)),
|
|
updated_at = NOW()
|
|
WHERE tenant_id = sqlc.arg(tenant_id);
|