Implement complete collection persistence with database-backed survival across server restarts
• Add full multi-table schema for collections with normalized design (collections, collection_templates, collection_items, collection_item_versions) • Implement collection detection and processing in enhancement pipeline for .insertr-add elements • Add template extraction and storage from existing HTML children with multi-variant support • Enable collection reconstruction from database on server restart with proper DOM rebuilding • Extend ContentClient interface with collection operations and full database integration • Update enhance command to use engine.DatabaseClient for collection persistence support
This commit is contained in:
39
internal/db/queries/collections.sql
Normal file
39
internal/db/queries/collections.sql
Normal file
@@ -0,0 +1,39 @@
|
||||
-- Collections table queries
|
||||
|
||||
-- name: GetCollection :one
|
||||
SELECT id, site_id, container_html, created_at, updated_at, last_edited_by
|
||||
FROM collections
|
||||
WHERE id = sqlc.arg(id) AND site_id = sqlc.arg(site_id);
|
||||
|
||||
-- name: GetAllCollections :many
|
||||
SELECT id, site_id, container_html, created_at, updated_at, last_edited_by
|
||||
FROM collections
|
||||
WHERE site_id = sqlc.arg(site_id)
|
||||
ORDER BY updated_at DESC;
|
||||
|
||||
-- name: CreateCollection :one
|
||||
INSERT INTO collections (id, site_id, container_html, last_edited_by)
|
||||
VALUES (sqlc.arg(id), sqlc.arg(site_id), sqlc.arg(container_html), sqlc.arg(last_edited_by))
|
||||
RETURNING id, site_id, container_html, created_at, updated_at, last_edited_by;
|
||||
|
||||
-- name: UpdateCollection :one
|
||||
UPDATE collections
|
||||
SET container_html = sqlc.arg(container_html), last_edited_by = sqlc.arg(last_edited_by)
|
||||
WHERE id = sqlc.arg(id) AND site_id = sqlc.arg(site_id)
|
||||
RETURNING id, site_id, container_html, created_at, updated_at, last_edited_by;
|
||||
|
||||
-- name: UpsertCollection :one
|
||||
INSERT INTO collections (id, site_id, container_html, last_edited_by)
|
||||
VALUES (sqlc.arg(id), sqlc.arg(site_id), sqlc.arg(container_html), sqlc.arg(last_edited_by))
|
||||
ON CONFLICT(id, site_id) DO UPDATE SET
|
||||
container_html = EXCLUDED.container_html,
|
||||
last_edited_by = EXCLUDED.last_edited_by
|
||||
RETURNING id, site_id, container_html, created_at, updated_at, last_edited_by;
|
||||
|
||||
-- name: DeleteCollection :exec
|
||||
DELETE FROM collections
|
||||
WHERE id = sqlc.arg(id) AND site_id = sqlc.arg(site_id);
|
||||
|
||||
-- name: DeleteAllSiteCollections :exec
|
||||
DELETE FROM collections
|
||||
WHERE site_id = sqlc.arg(site_id);
|
||||
Reference in New Issue
Block a user