Newsletter: every part editable and movable
A draft is one ordered list of parts (migration 060, newsletters.layout as JSON), edited with the content block editor so any part can be moved, copied or removed, each aligned left or center: - header: words, a PNG/JPEG logo, band color or none - title - any email block; dividers take color, thickness and spacing - picked items: events, posts or front page cards picked in order, with the heading, its underline, the card bar and the button label - footer: its lines and the line above Colors come from the palette or none. 057's fixed fields and blocks are dropped; that migration never reached a live database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
222c9e69a2
commit
3194fdbb7d
5 changed files with 561 additions and 397 deletions
47
server/src/migrations/060_newsletter_layout.sql
Normal file
47
server/src/migrations/060_newsletter_layout.sql
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 060 NEWSLETTER LAYOUT
|
||||
--
|
||||
-- A newsletter is one ordered list of parts now, each movable and
|
||||
-- each with its own settings (src/lib/newsletter.ts reads them):
|
||||
-- the header band, the title, any email block, a section of picked
|
||||
-- events, posts or front page cards, and the footer. It's kept as
|
||||
-- JSON in `layout`, the builder's only editor.
|
||||
--
|
||||
-- That replaces 057's fixed fields (intro, footer, picks) and the
|
||||
-- drafts' content_blocks. 057 never reached a live database, so
|
||||
-- there are no drafts to carry over: the table is rebuilt keeping
|
||||
-- each row's id, title and dates, and its blocks are deleted.
|
||||
-- `title` stays as its own column, for the list of drafts.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
DELETE FROM content_blocks WHERE owner_kind = 'newsletter';
|
||||
|
||||
DROP TRIGGER newsletters_touch;
|
||||
DROP TRIGGER newsletters_cleanup;
|
||||
|
||||
CREATE TABLE newsletters_new (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT,
|
||||
layout TEXT NOT NULL DEFAULT '[]' CHECK (json_valid(layout) AND json_type(layout) = 'array'),
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO newsletters_new (id, title, created_at, updated_at)
|
||||
SELECT id, title, created_at, updated_at FROM newsletters;
|
||||
|
||||
-- content_blocks_owner_exists names this table.
|
||||
PRAGMA legacy_alter_table = ON;
|
||||
DROP TABLE newsletters;
|
||||
ALTER TABLE newsletters_new RENAME TO newsletters;
|
||||
PRAGMA legacy_alter_table = OFF;
|
||||
|
||||
|
||||
-- ── Triggers last (see CLAUDE.md, Migrations) ──
|
||||
|
||||
CREATE TRIGGER newsletters_touch
|
||||
AFTER UPDATE ON newsletters
|
||||
FOR EACH ROW WHEN new.updated_at = old.updated_at
|
||||
BEGIN
|
||||
UPDATE newsletters SET updated_at = datetime('now') WHERE id = new.id;
|
||||
END;
|
||||
Loading…
Add table
Add a link
Reference in a new issue