Files
insertr/internal/db/sqlite/setup.sql.go
Joakim 2315ba4750 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
2025-09-22 18:29:58 +02:00

123 lines
4.1 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: setup.sql
package sqlite
import (
"context"
)
const initializeCollectionItemVersionsTable = `-- name: InitializeCollectionItemVersionsTable :exec
CREATE TABLE IF NOT EXISTS collection_item_versions (
version_id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id TEXT NOT NULL,
collection_id TEXT NOT NULL,
site_id TEXT NOT NULL,
html_content TEXT NOT NULL,
template_id INTEGER NOT NULL,
position INTEGER NOT NULL,
created_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
created_by TEXT DEFAULT 'system' NOT NULL,
FOREIGN KEY (item_id, collection_id, site_id) REFERENCES collection_items(item_id, collection_id, site_id) ON DELETE CASCADE
)
`
func (q *Queries) InitializeCollectionItemVersionsTable(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, initializeCollectionItemVersionsTable)
return err
}
const initializeCollectionItemsTable = `-- name: InitializeCollectionItemsTable :exec
CREATE TABLE IF NOT EXISTS collection_items (
item_id TEXT NOT NULL,
collection_id TEXT NOT NULL,
site_id TEXT NOT NULL,
template_id INTEGER NOT NULL,
html_content TEXT NOT NULL,
position INTEGER NOT NULL,
created_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
updated_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
last_edited_by TEXT DEFAULT 'system' NOT NULL,
PRIMARY KEY (item_id, collection_id, site_id),
FOREIGN KEY (collection_id, site_id) REFERENCES collections(id, site_id) ON DELETE CASCADE,
FOREIGN KEY (template_id) REFERENCES collection_templates(template_id) ON DELETE RESTRICT
)
`
func (q *Queries) InitializeCollectionItemsTable(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, initializeCollectionItemsTable)
return err
}
const initializeCollectionTemplatesTable = `-- name: InitializeCollectionTemplatesTable :exec
CREATE TABLE IF NOT EXISTS collection_templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT,
collection_id TEXT NOT NULL,
site_id TEXT NOT NULL,
name TEXT NOT NULL,
html_template TEXT NOT NULL,
is_default INTEGER DEFAULT 0 NOT NULL,
created_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
FOREIGN KEY (collection_id, site_id) REFERENCES collections(id, site_id) ON DELETE CASCADE
)
`
func (q *Queries) InitializeCollectionTemplatesTable(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, initializeCollectionTemplatesTable)
return err
}
const initializeCollectionsTable = `-- name: InitializeCollectionsTable :exec
CREATE TABLE IF NOT EXISTS collections (
id TEXT NOT NULL,
site_id TEXT NOT NULL,
container_html TEXT NOT NULL,
created_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
updated_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
last_edited_by TEXT DEFAULT 'system' NOT NULL,
PRIMARY KEY (id, site_id)
)
`
func (q *Queries) InitializeCollectionsTable(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, initializeCollectionsTable)
return err
}
const initializeSchema = `-- name: InitializeSchema :exec
CREATE TABLE IF NOT EXISTS content (
id TEXT NOT NULL,
site_id TEXT NOT NULL,
html_content TEXT NOT NULL,
original_template TEXT,
created_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
updated_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
last_edited_by TEXT DEFAULT 'system' NOT NULL,
PRIMARY KEY (id, site_id)
)
`
func (q *Queries) InitializeSchema(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, initializeSchema)
return err
}
const initializeVersionsTable = `-- name: InitializeVersionsTable :exec
CREATE TABLE IF NOT EXISTS content_versions (
version_id INTEGER PRIMARY KEY AUTOINCREMENT,
content_id TEXT NOT NULL,
site_id TEXT NOT NULL,
html_content TEXT NOT NULL,
original_template TEXT,
created_at INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL,
created_by TEXT DEFAULT 'system' NOT NULL
)
`
func (q *Queries) InitializeVersionsTable(ctx context.Context) error {
_, err := q.db.ExecContext(ctx, initializeVersionsTable)
return err
}