HifiPlanet-Website/hifi/api/src/Support/Schema.php
Maaxxs 260cd0700e Add generic per-field text styling (font/size/color), starting with home sections
Adds a new text_styles table keyed by field_key ("{table}.{slugOrId}.{column}")
so any individual text field anywhere in the dashboard can get its own
font-family/font-size/color override, without a dedicated column per field.
App\Support\TextStyleFields is a server-side registry of which table/column/
permission combinations are valid, so TextStyleController::update() can't be
used to write styling for a field outside the caller's own permission domain,
and typos can't create permanently orphaned rows. Resetting all three values
deletes the row entirely rather than leaving it null, so the table only ever
holds fields an admin actually customized.

Font-size reuses the same "curated list, mirrored PHP+JS constant" approach
already used for font-family (App\Support\Fonts / fontOptions.js) - a free px
input on dozens of independently-edited fields with no design review step is
the most likely way to end up with an accidentally 4px or 400px heading.

New reusable pieces: TextStyleWidget.jsx (a self-contained font/size/color
toolbar with a live preview, used next to any field by passing its
field_key) and TextStylesContext.jsx + useTextStyle() hook (bulk-fetches all
styles once per page load in PublicLayout.jsx, same pattern as
SiteSettingsContext). This first phase wires both into the home-section
eyebrow/title/button-label fields (the ones from the screenshot that started
this) as a proven pilot; the registry is designed so extending it to the
remaining ~15 admin pages is just adding entries and wiring the widget/hook,
no new architecture.

Verified locally via direct PHP invocation: migration creates the table,
registry validation accepts only known table/slug-or-id/column
combinations and rejects the rest, upsert/reset round-trips correctly, and
a second migration run doesn't re-touch anything.

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

613 lines
31 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Support;
/**
* Soll-Zustand der Datenbankstruktur für den aktuellen Code-Stand. Wird genutzt,
* um zu prüfen, ob eine (z. B. ältere) Live-Datenbank noch Tabellen oder Spalten
* vermissen lässt, und um diese bei Bedarf additiv nachzurüsten (nichts wird
* gelöscht oder verändert, was schon da ist).
*/
class Schema
{
// Reihenfolge ist wichtig wegen Foreign-Key-Abhängigkeiten (erst referenzierte Tabellen).
public const CREATE_STATEMENTS = [
'admin_users' => "CREATE TABLE admin_users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(64) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
is_super_admin TINYINT(1) NOT NULL DEFAULT 0,
two_factor_secret VARCHAR(64) NULL,
two_factor_enabled TINYINT(1) NOT NULL DEFAULT 0,
two_factor_recovery_codes TEXT NULL,
last_active_at DATETIME NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'app_settings' => "CREATE TABLE app_settings (
id INT PRIMARY KEY DEFAULT 1,
maintenance_global TINYINT(1) NOT NULL DEFAULT 0,
maintenance_global_message VARCHAR(500) NULL,
maintenance_services TINYINT(1) NOT NULL DEFAULT 0,
maintenance_services_message VARCHAR(500) NULL,
maintenance_vehicles TINYINT(1) NOT NULL DEFAULT 0,
maintenance_vehicles_message VARCHAR(500) NULL,
phone VARCHAR(50) NULL,
whatsapp VARCHAR(50) NULL,
contact_email VARCHAR(150) NULL,
address_street VARCHAR(150) NULL,
address_zip VARCHAR(20) NULL,
address_city VARCHAR(100) NULL,
logo_path VARCHAR(255) NULL,
logo_dark_path VARCHAR(255) NULL,
business_hours TEXT NULL,
hero_image_path VARCHAR(255) NULL,
ga_measurement_id VARCHAR(20) NULL,
ga_property_id VARCHAR(30) NULL,
google_place_id VARCHAR(255) NULL,
google_places_api_key VARCHAR(255) NULL,
google_rating DECIMAL(2,1) NULL,
google_rating_count INT NULL,
google_reviews_updated_at DATETIME NULL,
google_reviews_error VARCHAR(500) NULL,
package_card_theme VARCHAR(30) NOT NULL DEFAULT 'graphite',
package_card_layout VARCHAR(20) NOT NULL DEFAULT 'strip',
package_wheel_hint_interval INT NOT NULL DEFAULT 8,
gallery_card_text_x TINYINT UNSIGNED NOT NULL DEFAULT 0,
gallery_card_text_y TINYINT UNSIGNED NOT NULL DEFAULT 100,
site_font VARCHAR(255) NULL,
mail_host VARCHAR(255) NULL,
mail_port INT NULL,
mail_username VARCHAR(255) NULL,
mail_password VARCHAR(255) NULL,
mail_encryption VARCHAR(10) NOT NULL DEFAULT 'tls',
mail_from_email VARCHAR(150) NULL,
mail_from_name VARCHAR(150) NULL,
mail_notify_email VARCHAR(150) NULL,
mail_customer_subject VARCHAR(255) NULL,
mail_customer_body TEXT NULL,
mail_owner_subject VARCHAR(255) NULL,
mail_owner_body TEXT NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
// Rechtstexte (Impressum/Datenschutz/AGB) als editierbare Seiten statt hart codierter
// React-Komponenten. Fehlt eine Zeile fuer einen Slug (z.B. frisch installierte Seite),
// liefert PageContentController einen eingebauten Standardtext (siehe DEFAULTS dort) -
// die Tabelle muss dafuer nicht vorab befuellt werden.
'legal_pages' => "CREATE TABLE 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",
// Die wichtigsten Text-Abschnitte der Startseite (YouTube-Sektion, Handwerk/Beratung,
// Einblicke, "Mehr als Car-Hifi") als editierbare Bloecke statt hart im JSX codiert -
// zweisprachig wie faqs, da die Seite einen Sprachumschalter hat. Fehlt eine Zeile
// fuer einen Slug, liefert HomeSectionController denselben Text, der zuvor im
// i18n-Woerterbuch stand (siehe DEFAULTS dort).
'home_sections' => "CREATE TABLE home_sections (
id INT AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(50) NOT NULL UNIQUE,
eyebrow_de VARCHAR(150) NULL,
eyebrow_en VARCHAR(150) NULL,
title_de VARCHAR(255) NULL,
title_en VARCHAR(255) NULL,
body_html_de TEXT NULL,
body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
text_align_x TINYINT UNSIGNED NOT NULL DEFAULT 50,
text_align_y TINYINT UNSIGNED NOT NULL DEFAULT 50,
button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL,
font_family VARCHAR(255) NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'services' => "CREATE TABLE services (
id INT AUTO_INCREMENT PRIMARY KEY,
icon_name VARCHAR(100) NOT NULL,
title VARCHAR(150) NOT NULL,
description TEXT NOT NULL,
image_path VARCHAR(255) NULL,
cta_label VARCHAR(100) NULL,
cta_url VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'permission_groups' => "CREATE TABLE permission_groups (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL UNIQUE,
description VARCHAR(255) NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'permission_group_permissions' => "CREATE TABLE permission_group_permissions (
permission_group_id INT NOT NULL,
permission VARCHAR(64) NOT NULL,
PRIMARY KEY (permission_group_id, permission),
CONSTRAINT fk_pgp_group FOREIGN KEY (permission_group_id) REFERENCES permission_groups(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'admin_user_permissions' => "CREATE TABLE admin_user_permissions (
admin_user_id INT NOT NULL,
permission VARCHAR(64) NOT NULL,
PRIMARY KEY (admin_user_id, permission),
CONSTRAINT fk_aup_user FOREIGN KEY (admin_user_id) REFERENCES admin_users(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'admin_user_groups' => "CREATE TABLE admin_user_groups (
admin_user_id INT NOT NULL,
permission_group_id INT NOT NULL,
PRIMARY KEY (admin_user_id, permission_group_id),
CONSTRAINT fk_aug_user FOREIGN KEY (admin_user_id) REFERENCES admin_users(id) ON DELETE CASCADE,
CONSTRAINT fk_aug_group FOREIGN KEY (permission_group_id) REFERENCES permission_groups(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'brands' => "CREATE TABLE brands (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
slug VARCHAR(120) NOT NULL UNIQUE,
image_path VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'partners' => "CREATE TABLE partners (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
logo_path VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
// Generischer Stil (Schriftart/-groesse/Farbe) pro einzelnem Textfeld irgendwo im
// Dashboard, statt eigener Spalten pro Tabelle/Feld - field_key identifiziert das Feld
// eindeutig (Format "{tabelle}.{slugOderId}.{spalte}", siehe TextStyleFields::TABLES,
// das serverseitig validiert welche Kombinationen erlaubt sind). VARCHAR(190) statt 255,
// damit der UNIQUE-Index unter dem utf8mb4-Limit bleibt.
'text_styles' => "CREATE TABLE text_styles (
id INT AUTO_INCREMENT PRIMARY KEY,
field_key VARCHAR(190) NOT NULL UNIQUE,
font_family VARCHAR(255) NULL,
font_size VARCHAR(20) NULL,
color VARCHAR(20) NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'car_models' => "CREATE TABLE car_models (
id INT AUTO_INCREMENT PRIMARY KEY,
brand_id INT NOT NULL,
name VARCHAR(100) NOT NULL,
slug VARCHAR(150) NOT NULL,
image_path VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uniq_brand_slug (brand_id, slug),
CONSTRAINT fk_car_models_brand FOREIGN KEY (brand_id) REFERENCES brands(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'gallery_brands' => "CREATE TABLE gallery_brands (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
slug VARCHAR(120) NOT NULL UNIQUE,
cover_image_path VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'gallery_projects' => "CREATE TABLE gallery_projects (
id INT AUTO_INCREMENT PRIMARY KEY,
gallery_brand_id INT NOT NULL,
name VARCHAR(100) NOT NULL,
slug VARCHAR(150) NOT NULL,
cover_image_path VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uniq_gallery_brand_slug (gallery_brand_id, slug),
CONSTRAINT fk_gallery_projects_brand FOREIGN KEY (gallery_brand_id) REFERENCES gallery_brands(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'gallery_photos' => "CREATE TABLE gallery_photos (
id INT AUTO_INCREMENT PRIMARY KEY,
gallery_project_id INT NOT NULL,
image_path VARCHAR(255) NOT NULL,
caption VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT fk_gallery_photos_project FOREIGN KEY (gallery_project_id) REFERENCES gallery_projects(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'packages' => "CREATE TABLE packages (
id INT AUTO_INCREMENT PRIMARY KEY,
car_model_id INT NOT NULL,
name VARCHAR(150) NOT NULL,
slug VARCHAR(170) NOT NULL,
description TEXT NULL,
markup_type ENUM('none','fixed','percent') NOT NULL DEFAULT 'none',
markup_value DECIMAL(10,2) NOT NULL DEFAULT 0,
icon_name VARCHAR(100) NULL,
tagline VARCHAR(150) NULL,
price_text VARCHAR(100) NULL,
is_featured TINYINT(1) NOT NULL DEFAULT 0,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uniq_model_slug (car_model_id, slug),
CONSTRAINT fk_packages_model FOREIGN KEY (car_model_id) REFERENCES car_models(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'package_upgrades' => "CREATE TABLE package_upgrades (
id INT AUTO_INCREMENT PRIMARY KEY,
package_id INT NOT NULL,
name VARCHAR(150) NOT NULL,
description VARCHAR(255) NULL,
price DECIMAL(10,2) NOT NULL DEFAULT 0,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT fk_upgrades_package FOREIGN KEY (package_id) REFERENCES packages(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'package_products' => "CREATE TABLE package_products (
id INT AUTO_INCREMENT PRIMARY KEY,
package_id INT NOT NULL,
source_url VARCHAR(500) NOT NULL,
name_override VARCHAR(255) NULL,
scraped_name VARCHAR(255) NULL,
scraped_price DECIMAL(10,2) NULL,
scraped_currency VARCHAR(8) NOT NULL DEFAULT 'EUR',
scraped_image_url VARCHAR(500) NULL,
price_updated_at DATETIME NULL,
scrape_status ENUM('pending','ok','error') NOT NULL DEFAULT 'pending',
scrape_error VARCHAR(255) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT fk_products_package FOREIGN KEY (package_id) REFERENCES packages(id) ON DELETE CASCADE
) ENGINE=InnoDB",
'faqs' => "CREATE TABLE faqs (
id INT AUTO_INCREMENT PRIMARY KEY,
question_de TEXT NOT NULL,
answer_de TEXT NOT NULL,
question_en TEXT NOT NULL,
answer_en TEXT NOT NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB",
'contact_requests' => "CREATE TABLE contact_requests (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(150) NOT NULL,
email VARCHAR(150) NOT NULL,
phone VARCHAR(50) NULL,
vin VARCHAR(50) NULL,
message TEXT NULL,
brand_name VARCHAR(100) NULL,
model_name VARCHAR(100) NULL,
package_name VARCHAR(150) NULL,
product_name VARCHAR(255) NULL,
package_id INT NULL,
package_product_id INT NULL,
selected_upgrades TEXT NULL,
status ENUM('new','in_progress','done') NOT NULL DEFAULT 'new',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_contact_package FOREIGN KEY (package_id) REFERENCES packages(id) ON DELETE SET NULL,
CONSTRAINT fk_contact_product FOREIGN KEY (package_product_id) REFERENCES package_products(id) ON DELETE SET NULL
) ENGINE=InnoDB",
// Reiner Cache der letzten Google-Places-Abfrage (siehe GooglePlacesReviewsFetcher) -
// wird bei jedem erfolgreichen Refresh komplett neu befuellt (DELETE + INSERT),
// keine eigenen Fremdschluessel-Bezuege von aussen.
'google_reviews' => "CREATE TABLE google_reviews (
id INT AUTO_INCREMENT PRIMARY KEY,
google_review_id VARCHAR(255) NULL,
author_name VARCHAR(150) NOT NULL,
profile_photo_url VARCHAR(500) NULL,
rating TINYINT NOT NULL,
review_text TEXT NULL,
relative_time_description VARCHAR(100) NULL,
review_time INT NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB",
];
// Erwartete Spalten je Tabelle (ohne Primary Key / Unique / Foreign-Key-Klauseln –
// die werden nur bei der Tabellen-Neuanlage berücksichtigt, nicht beim Nachrüsten
// einzelner Spalten). Reihenfolge = Definitionsreihenfolge, "id" wird beim
// Spalten-Nachrüsten übersprungen (Primary Key kann nicht nachträglich per
// ADD COLUMN ergänzt werden, ist aber immer vorhanden, wenn die Tabelle existiert).
public const COLUMNS = [
'admin_users' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'username' => 'VARCHAR(64) NOT NULL',
'password_hash' => 'VARCHAR(255) NOT NULL',
'is_super_admin' => 'TINYINT(1) NOT NULL DEFAULT 0',
'two_factor_secret' => 'VARCHAR(64) NULL',
'two_factor_enabled' => 'TINYINT(1) NOT NULL DEFAULT 0',
'two_factor_recovery_codes' => 'TEXT NULL',
'last_active_at' => 'DATETIME NULL',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
],
'app_settings' => [
'id' => 'INT PRIMARY KEY DEFAULT 1',
'maintenance_global' => 'TINYINT(1) NOT NULL DEFAULT 0',
'maintenance_global_message' => 'VARCHAR(500) NULL',
'maintenance_services' => 'TINYINT(1) NOT NULL DEFAULT 0',
'maintenance_services_message' => 'VARCHAR(500) NULL',
'maintenance_vehicles' => 'TINYINT(1) NOT NULL DEFAULT 0',
'maintenance_vehicles_message' => 'VARCHAR(500) NULL',
'phone' => 'VARCHAR(50) NULL',
'whatsapp' => 'VARCHAR(50) NULL',
'contact_email' => 'VARCHAR(150) NULL',
'address_street' => 'VARCHAR(150) NULL',
'address_zip' => 'VARCHAR(20) NULL',
'address_city' => 'VARCHAR(100) NULL',
'logo_path' => 'VARCHAR(255) NULL',
'logo_dark_path' => 'VARCHAR(255) NULL',
'business_hours' => 'TEXT NULL',
'hero_image_path' => 'VARCHAR(255) NULL',
'ga_measurement_id' => 'VARCHAR(20) NULL',
'ga_property_id' => 'VARCHAR(30) NULL',
'google_place_id' => 'VARCHAR(255) NULL',
'google_places_api_key' => 'VARCHAR(255) NULL',
'google_rating' => 'DECIMAL(2,1) NULL',
'google_rating_count' => 'INT NULL',
'google_reviews_updated_at' => 'DATETIME NULL',
'google_reviews_error' => 'VARCHAR(500) NULL',
'package_card_theme' => "VARCHAR(30) NOT NULL DEFAULT 'graphite'",
'package_card_layout' => "VARCHAR(20) NOT NULL DEFAULT 'strip'",
'package_wheel_hint_interval' => 'INT NOT NULL DEFAULT 8',
'gallery_card_text_x' => 'TINYINT UNSIGNED NOT NULL DEFAULT 0',
'gallery_card_text_y' => 'TINYINT UNSIGNED NOT NULL DEFAULT 100',
'site_font' => 'VARCHAR(255) NULL',
'mail_host' => 'VARCHAR(255) NULL',
'mail_port' => 'INT NULL',
'mail_username' => 'VARCHAR(255) NULL',
'mail_password' => 'VARCHAR(255) NULL',
'mail_encryption' => "VARCHAR(10) NOT NULL DEFAULT 'tls'",
'mail_from_email' => 'VARCHAR(150) NULL',
'mail_from_name' => 'VARCHAR(150) NULL',
'mail_notify_email' => 'VARCHAR(150) NULL',
'mail_customer_subject' => 'VARCHAR(255) NULL',
'mail_customer_body' => 'TEXT NULL',
'mail_owner_subject' => 'VARCHAR(255) NULL',
'mail_owner_body' => 'TEXT NULL',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'legal_pages' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'slug' => 'VARCHAR(50) NOT NULL',
'title' => 'VARCHAR(150) NOT NULL',
'body_html' => 'TEXT NOT NULL',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'home_sections' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'slug' => 'VARCHAR(50) NOT NULL',
'eyebrow_de' => 'VARCHAR(150) NULL',
'eyebrow_en' => 'VARCHAR(150) NULL',
'title_de' => 'VARCHAR(255) NULL',
'title_en' => 'VARCHAR(255) NULL',
'body_html_de' => 'TEXT NULL',
'body_html_en' => 'TEXT NULL',
'text_align' => "ENUM('left','center','right') NOT NULL DEFAULT 'center'",
'text_align_x' => 'TINYINT UNSIGNED NOT NULL DEFAULT 50',
'text_align_y' => 'TINYINT UNSIGNED NOT NULL DEFAULT 50',
'button_label_de' => 'VARCHAR(100) NULL',
'button_label_en' => 'VARCHAR(100) NULL',
'button_url' => 'VARCHAR(500) NULL',
'font_family' => 'VARCHAR(255) NULL',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'services' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'icon_name' => 'VARCHAR(100) NOT NULL',
'title' => 'VARCHAR(150) NOT NULL',
'description' => 'TEXT NOT NULL',
'image_path' => 'VARCHAR(255) NULL',
'cta_label' => 'VARCHAR(100) NULL',
'cta_url' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'permission_groups' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'name' => 'VARCHAR(100) NOT NULL',
'description' => 'VARCHAR(255) NULL',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'permission_group_permissions' => [
'permission_group_id' => 'INT NOT NULL',
'permission' => 'VARCHAR(64) NOT NULL',
],
'admin_user_permissions' => [
'admin_user_id' => 'INT NOT NULL',
'permission' => 'VARCHAR(64) NOT NULL',
],
'admin_user_groups' => [
'admin_user_id' => 'INT NOT NULL',
'permission_group_id' => 'INT NOT NULL',
],
'brands' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'name' => 'VARCHAR(100) NOT NULL',
'slug' => 'VARCHAR(120) NOT NULL',
'image_path' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'partners' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'name' => 'VARCHAR(100) NOT NULL',
'logo_path' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'text_styles' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'field_key' => 'VARCHAR(190) NOT NULL',
'font_family' => 'VARCHAR(255) NULL',
'font_size' => 'VARCHAR(20) NULL',
'color' => 'VARCHAR(20) NULL',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'car_models' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'brand_id' => 'INT NOT NULL',
'name' => 'VARCHAR(100) NOT NULL',
'slug' => 'VARCHAR(150) NOT NULL',
'image_path' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'gallery_brands' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'name' => 'VARCHAR(100) NOT NULL',
'slug' => 'VARCHAR(120) NOT NULL',
'cover_image_path' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'gallery_projects' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'gallery_brand_id' => 'INT NOT NULL',
'name' => 'VARCHAR(100) NOT NULL',
'slug' => 'VARCHAR(150) NOT NULL',
'cover_image_path' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'gallery_photos' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'gallery_project_id' => 'INT NOT NULL',
'image_path' => 'VARCHAR(255) NOT NULL',
'caption' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'packages' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'car_model_id' => 'INT NOT NULL',
'name' => 'VARCHAR(150) NOT NULL',
'slug' => 'VARCHAR(170) NOT NULL',
'description' => 'TEXT NULL',
'markup_type' => "ENUM('none','fixed','percent') NOT NULL DEFAULT 'none'",
'markup_value' => 'DECIMAL(10,2) NOT NULL DEFAULT 0',
'icon_name' => 'VARCHAR(100) NULL',
'tagline' => 'VARCHAR(150) NULL',
'price_text' => 'VARCHAR(100) NULL',
'is_featured' => 'TINYINT(1) NOT NULL DEFAULT 0',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'package_upgrades' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'package_id' => 'INT NOT NULL',
'name' => 'VARCHAR(150) NOT NULL',
'description' => 'VARCHAR(255) NULL',
'price' => 'DECIMAL(10,2) NOT NULL DEFAULT 0',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'package_products' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'package_id' => 'INT NOT NULL',
'source_url' => 'VARCHAR(500) NOT NULL',
'name_override' => 'VARCHAR(255) NULL',
'scraped_name' => 'VARCHAR(255) NULL',
'scraped_price' => 'DECIMAL(10,2) NULL',
'scraped_currency' => "VARCHAR(8) NOT NULL DEFAULT 'EUR'",
'scraped_image_url' => 'VARCHAR(500) NULL',
'price_updated_at' => 'DATETIME NULL',
'scrape_status' => "ENUM('pending','ok','error') NOT NULL DEFAULT 'pending'",
'scrape_error' => 'VARCHAR(255) NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'faqs' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'question_de' => 'TEXT NOT NULL',
'answer_de' => 'TEXT NOT NULL',
'question_en' => 'TEXT NOT NULL',
'answer_en' => 'TEXT NOT NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
],
'contact_requests' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'name' => 'VARCHAR(150) NOT NULL',
'email' => 'VARCHAR(150) NOT NULL',
'phone' => 'VARCHAR(50) NULL',
'vin' => 'VARCHAR(50) NULL',
'message' => 'TEXT NULL',
'brand_name' => 'VARCHAR(100) NULL',
'model_name' => 'VARCHAR(100) NULL',
'package_name' => 'VARCHAR(150) NULL',
'product_name' => 'VARCHAR(255) NULL',
'package_id' => 'INT NULL',
'package_product_id' => 'INT NULL',
'selected_upgrades' => 'TEXT NULL',
'status' => "ENUM('new','in_progress','done') NOT NULL DEFAULT 'new'",
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
],
'google_reviews' => [
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
'google_review_id' => 'VARCHAR(255) NULL',
'author_name' => 'VARCHAR(150) NOT NULL',
'profile_photo_url' => 'VARCHAR(500) NULL',
'rating' => 'TINYINT NOT NULL',
'review_text' => 'TEXT NULL',
'relative_time_description' => 'VARCHAR(100) NULL',
'review_time' => 'INT NULL',
'sort_order' => 'INT NOT NULL DEFAULT 0',
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
],
];
// Einmalige Startdaten fuer eine Tabelle, die von SchemaController::runMigration() direkt
// nach dem CREATE TABLE eingefuegt werden - nur in dem Moment, in dem die Tabelle neu
// angelegt wird, danach nie wieder (verhindert, dass absichtlich geloeschte Zeilen bei
// einem erneuten Klick auf "Datenbankstruktur aktualisieren" wieder auftauchen).
public const SEED_DATA = [
'partners' => [
['name' => 'Ground Zero Audio', 'sort_order' => 0],
['name' => 'Audison', 'sort_order' => 1],
['name' => 'Hertz', 'sort_order' => 2],
['name' => 'Helix', 'sort_order' => 3],
['name' => 'Brax', 'sort_order' => 4],
['name' => 'Gladen', 'sort_order' => 5],
['name' => 'Alpine', 'sort_order' => 6],
['name' => 'Pioneer', 'sort_order' => 7],
['name' => 'Kenwood', 'sort_order' => 8],
['name' => 'JVC', 'sort_order' => 9],
],
];
}