NGU-Web/server/src/migrations/046_content_requests.sql
Zaldimmar dc53af238f Add a Request form, with files in Google Drive and email notices
One form at /request for blog posts, events, and new or updated
chapters, regions (updates only), partners, teams, awards and people.
?type= opens it on one; buttons on the Community sections, blog posts,
Retreats and the front page calendar do. Files (.docx, PDF, JPEG, PNG)
go to a Google Drive folder through a service account.

Requests are feedback rows of type 'content' (migration 046), in a
third Forms queue: files download from Drive, a .docx can become a
draft blog post, and deleting a request deletes its files. New content
and data requests email the addresses in Site settings through Gmail.

Setup: docs/google-drive-and-mail.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:54:00 -05:00

39 lines
1.9 KiB
SQL

-- ═══════════════════════════════════════════════════════════════
-- 046 CONTENT REQUESTS
--
-- The Request form (/request): someone asks for a blog post, an
-- event, or a new or updated chapter, region, partner, team, award
-- or person, and can attach files (a .docx to fill in, photos).
-- Requests are feedback rows of type 'content', so they share the
-- admin's triage (Forms → Content requests): status, notes, delete.
--
-- category what it's about (REQUEST_TYPES in
-- src/data/requestTypes.ts)
-- request_action 'new' or 'update'
-- subject the title or name, or which record to update
--
-- The files themselves live in Google Drive (googleService.js);
-- feedback_files keeps Drive's id for each, and goes with its row.
--
-- site_settings.notify_emails: who gets an email for each new
-- content or data request (Panel → Site settings), comma separated.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE feedback ADD COLUMN category TEXT
CHECK (category IN ('blog', 'event', 'chapter', 'region', 'partner', 'team', 'award', 'person'));
ALTER TABLE feedback ADD COLUMN request_action TEXT
CHECK (request_action IN ('new', 'update'));
ALTER TABLE feedback ADD COLUMN subject TEXT;
CREATE TABLE feedback_files (
id INTEGER PRIMARY KEY AUTOINCREMENT,
feedback_id INTEGER NOT NULL REFERENCES feedback (id) ON DELETE CASCADE,
drive_id TEXT NOT NULL,
name TEXT NOT NULL,
mime TEXT NOT NULL,
size INTEGER NOT NULL
) STRICT;
CREATE INDEX feedback_files_owner_idx ON feedback_files (feedback_id);
ALTER TABLE site_settings ADD COLUMN notify_emails TEXT;