HifiPlanet-Website/hifi/api/database/migration_business_stammdaten.sql
Maaxxs 5f1d4e1092 Add CMS v1: editable business identity and legal pages
Phase 5 of the dashboard roadmap. Business-facing data that was
previously hard-coded (and, for address/hours, duplicated three
independent ways across Footer.jsx, ContactPage.jsx, and the i18n
strings) is now stored in app_settings and editable under Website
settings: logo (light/dark variants, falling back to the bundled
defaults until set), street/zip/city, and a day-by-day business_hours
editor. Footer.jsx and ContactPage.jsx now share one open/closed and
hours-formatting implementation (new utils/businessHours.js) instead
of three separate hard-coded representations of the same thing.

New legal_pages table (impressum/datenschutz/agb) + PageContentController
replaces the three fully hard-coded React pages with fetched, admin-
editable HTML - built-in defaults matching the original page content
kick in until an admin saves anything, so a fresh install isn't blank.
Reuses the Phase 4 RichTextEditor (extended with a heading toggle and
inline-code toggle, since the legal text needs both) via a new
"Rechtstexte" tab in Settings. Legal content lives only in DB and is
authored exclusively by logged-in admins, so dangerouslySetInnerHTML
here doesn't take untrusted input.

IMAGE_COLUMNS in SettingsController (export/import) is now table =>
array of columns instead of table => one column, since app_settings
has three image columns (hero/logo/logo_dark) - this also retroactively
fixes hero_image_path never having been wired into export/import at
all. app_settings and legal_pages both got TABLE_COLUMNS/IMPORT_SECTIONS
entries so they round-trip through a hoster-migration export like
everything else.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 02:03:59 +02:00

27 lines
1.5 KiB
SQL

USE hifi_shop;
-- Business-Stammdaten (Logo, Adresse, Oeffnungszeiten) direkt im Dashboard editierbar,
-- statt hart im Frontend-Code hinterlegt. Additiv, nichts wird geloescht.
-- Hinweis: Auf der Live-Seite reicht stattdessen ein Klick auf "Datenbankstruktur aktualisieren"
-- unter Admin-Panel -> Einstellungen -> Datenbank.
ALTER TABLE app_settings
ADD COLUMN IF NOT EXISTS address_street VARCHAR(150) NULL AFTER contact_email,
ADD COLUMN IF NOT EXISTS address_zip VARCHAR(20) NULL AFTER address_street,
ADD COLUMN IF NOT EXISTS address_city VARCHAR(100) NULL AFTER address_zip,
ADD COLUMN IF NOT EXISTS logo_path VARCHAR(255) NULL AFTER address_city,
ADD COLUMN IF NOT EXISTS logo_dark_path VARCHAR(255) NULL AFTER logo_path,
-- JSON pro Wochentag ({open, close, closed}) als Text gespeichert, wie schon
-- contact_requests.selected_upgrades - keine native JSON-Spalte im Rest des Schemas.
ADD COLUMN IF NOT EXISTS business_hours TEXT NULL AFTER logo_dark_path;
-- Rechtstexte (Impressum/Datenschutz/AGB) als editierbare Rich-Text-Seiten statt hart
-- codierter React-Komponenten. Fehlt eine Zeile fuer einen Slug, liefert
-- PageContentController einen eingebauten Standardtext (siehe DEFAULTS dort).
CREATE TABLE IF NOT EXISTS legal_pages (
id INT AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(50) NOT NULL UNIQUE,
title VARCHAR(150) NOT NULL,
body_html TEXT NOT NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;