66 lines
2.6 KiB
SQL
66 lines
2.6 KiB
SQL
-- Migration für Meta-Entries Tabelle
|
|
-- Führe diese SQL-Datei aus um die Tabelle zu erstellen
|
|
|
|
CREATE TABLE IF NOT EXISTS meta_entries (
|
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
|
|
-- Route-basierte Meta-Daten
|
|
route_pattern VARCHAR(255) NULL,
|
|
|
|
-- Entity-basierte Meta-Daten
|
|
entity_type VARCHAR(100) NULL,
|
|
entity_id INT NULL,
|
|
|
|
-- Meta-Daten Felder
|
|
title VARCHAR(255) NULL,
|
|
description TEXT NULL,
|
|
keywords TEXT NULL,
|
|
|
|
-- Open Graph
|
|
og_title VARCHAR(255) NULL,
|
|
og_description TEXT NULL,
|
|
og_image VARCHAR(500) NULL,
|
|
og_type VARCHAR(50) NULL,
|
|
|
|
-- Twitter
|
|
twitter_card VARCHAR(50) NULL,
|
|
twitter_site VARCHAR(100) NULL,
|
|
|
|
-- Andere
|
|
canonical VARCHAR(500) NULL,
|
|
custom_meta JSON NULL,
|
|
|
|
-- System-Felder
|
|
priority INT DEFAULT 0,
|
|
active BOOLEAN DEFAULT TRUE,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
-- Indizes
|
|
INDEX idx_route_pattern (route_pattern),
|
|
INDEX idx_entity (entity_type, entity_id),
|
|
INDEX idx_active_priority (active, priority),
|
|
|
|
-- Unique Constraints
|
|
UNIQUE KEY unique_route_pattern (route_pattern),
|
|
UNIQUE KEY unique_entity (entity_type, entity_id),
|
|
|
|
-- Constraints
|
|
CONSTRAINT check_route_or_entity CHECK (
|
|
(route_pattern IS NOT NULL AND entity_type IS NULL AND entity_id IS NULL) OR
|
|
(route_pattern IS NULL AND entity_type IS NOT NULL AND entity_id IS NOT NULL)
|
|
)
|
|
);
|
|
|
|
-- Beispiel-Daten einfügen
|
|
INSERT INTO meta_entries (route_pattern, title, description, og_title, og_type, priority, active) VALUES
|
|
('/', 'Startseite - Meine Website', 'Willkommen auf meiner Website. Hier finden Sie alles über...', 'Startseite', 'website', 100, TRUE),
|
|
('/blog', 'Blog - Meine Website', 'Alle Artikel und Neuigkeiten aus unserem Blog', 'Blog', 'website', 90, TRUE),
|
|
('/blog/*', 'Blog: {title} - Meine Website', '{description}', '{title}', 'article', 80, TRUE),
|
|
('/contact', 'Kontakt - Meine Website', 'Nehmen Sie Kontakt mit uns auf. Wir freuen uns auf Ihre Nachricht.', 'Kontakt', 'website', 70, TRUE);
|
|
|
|
-- Template-Beispiele mit Platzhaltern
|
|
INSERT INTO meta_entries (entity_type, entity_id, title, description, og_title, og_description, priority, active) VALUES
|
|
('product', 1, '{product.name} - Jetzt kaufen | Mein Shop', '{product.name} für nur {product.price}€. {truncate:product.description}', '{product.name}', '{truncate:product.description}', 100, TRUE),
|
|
('article', 1, '{article.title} | Mein Blog', '{truncate:article.content}', '{article.title}', '{truncate:article.content}', 100, TRUE);
|