This commit is contained in:
137
schema.sql
137
schema.sql
@@ -115,6 +115,143 @@ CREATE TABLE event_participants (
|
||||
CONSTRAINT fk_ep_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE system_settings (
|
||||
`key` VARCHAR(120) NOT NULL PRIMARY KEY,
|
||||
`value` TEXT NULL,
|
||||
updated_by BIGINT UNSIGNED NULL,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_system_settings_updated_by FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listing_categories (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
slug VARCHAR(120) NOT NULL UNIQUE,
|
||||
title VARCHAR(160) NOT NULL,
|
||||
category_group ENUM('general','event','place','food','family','partner') NOT NULL DEFAULT 'general',
|
||||
sort_order SMALLINT UNSIGNED 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 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listing_places (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
created_by BIGINT UNSIGNED NULL,
|
||||
source_type ENUM('user','partner','admin','system') NOT NULL DEFAULT 'user',
|
||||
title VARCHAR(180) NOT NULL,
|
||||
description TEXT NULL,
|
||||
street VARCHAR(180) NULL,
|
||||
zip CHAR(5) NULL,
|
||||
city VARCHAR(120) NULL,
|
||||
region VARCHAR(120) NULL,
|
||||
lat DECIMAL(10,7) NULL,
|
||||
lng DECIMAL(10,7) NULL,
|
||||
website_url VARCHAR(255) NULL,
|
||||
phone VARCHAR(60) NULL,
|
||||
place_kind VARCHAR(80) NULL,
|
||||
provider_hint ENUM('manual','osm','google') NOT NULL DEFAULT 'manual',
|
||||
external_place_id VARCHAR(190) NULL,
|
||||
google_place_id VARCHAR(190) NULL,
|
||||
rating_value DECIMAL(3,2) NULL,
|
||||
rating_count INT UNSIGNED NULL,
|
||||
status ENUM('draft','published','archived') NOT NULL DEFAULT 'published',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_listing_places_user FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_listing_places_city (city),
|
||||
INDEX idx_listing_places_region (region),
|
||||
INDEX idx_listing_places_latlng (lat,lng),
|
||||
INDEX idx_listing_places_kind (place_kind)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listings (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
created_by BIGINT UNSIGNED NULL,
|
||||
owner_type ENUM('user','partner','admin','system') NOT NULL DEFAULT 'user',
|
||||
listing_type ENUM('event','partner_offer','place','editorial_event') NOT NULL DEFAULT 'event',
|
||||
primary_place_id BIGINT UNSIGNED NULL,
|
||||
title VARCHAR(200) NOT NULL,
|
||||
teaser_public VARCHAR(280) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
visibility ENUM('public','members') NOT NULL DEFAULT 'public',
|
||||
status ENUM('draft','published','cancelled','archived') NOT NULL DEFAULT 'draft',
|
||||
supports_registration TINYINT(1) NOT NULL DEFAULT 0,
|
||||
supports_capacity TINYINT(1) NOT NULL DEFAULT 0,
|
||||
supports_pricing TINYINT(1) NOT NULL DEFAULT 0,
|
||||
is_recurring TINYINT(1) NOT NULL DEFAULT 0,
|
||||
legacy_event_id BIGINT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_listings_user FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_listings_place FOREIGN KEY (primary_place_id) REFERENCES listing_places(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_listings_legacy_event FOREIGN KEY (legacy_event_id) REFERENCES events(id) ON DELETE SET NULL,
|
||||
INDEX idx_listings_type (listing_type),
|
||||
INDEX idx_listings_status (status),
|
||||
INDEX idx_listings_owner (owner_type)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listing_category_map (
|
||||
listing_id BIGINT UNSIGNED NOT NULL,
|
||||
category_id BIGINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (listing_id, category_id),
|
||||
CONSTRAINT fk_lcm_listing FOREIGN KEY (listing_id) REFERENCES listings(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_lcm_category FOREIGN KEY (category_id) REFERENCES listing_categories(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listing_occurrences (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
listing_id BIGINT UNSIGNED NOT NULL,
|
||||
occurrence_type ENUM('single','series','range','open_ended') NOT NULL DEFAULT 'single',
|
||||
starts_at DATETIME NULL,
|
||||
ends_at DATETIME NULL,
|
||||
recurrence_rule VARCHAR(255) NULL,
|
||||
recurrence_until DATETIME NULL,
|
||||
capacity_total SMALLINT UNSIGNED NULL,
|
||||
booking_url VARCHAR(255) NULL,
|
||||
status ENUM('scheduled','cancelled','sold_out') NOT NULL DEFAULT 'scheduled',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_listing_occurrences_listing FOREIGN KEY (listing_id) REFERENCES listings(id) ON DELETE CASCADE,
|
||||
INDEX idx_listing_occurrences_start (starts_at),
|
||||
INDEX idx_listing_occurrences_type (occurrence_type),
|
||||
INDEX idx_listing_occurrences_status (status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listing_prices (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
listing_id BIGINT UNSIGNED NOT NULL,
|
||||
occurrence_id BIGINT UNSIGNED NULL,
|
||||
label VARCHAR(120) NOT NULL,
|
||||
audience ENUM('general','adult','child','family','group') NOT NULL DEFAULT 'general',
|
||||
price_type ENUM('free','fixed','from','up_to','range','request') NOT NULL DEFAULT 'fixed',
|
||||
amount DECIMAL(10,2) NULL,
|
||||
amount_secondary DECIMAL(10,2) NULL,
|
||||
currency CHAR(3) NOT NULL DEFAULT 'EUR',
|
||||
note VARCHAR(255) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_listing_prices_listing FOREIGN KEY (listing_id) REFERENCES listings(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_listing_prices_occurrence FOREIGN KEY (occurrence_id) REFERENCES listing_occurrences(id) ON DELETE CASCADE,
|
||||
INDEX idx_listing_prices_listing (listing_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE listing_benefits (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
listing_id BIGINT UNSIGNED NOT NULL,
|
||||
occurrence_id BIGINT UNSIGNED NULL,
|
||||
benefit_type ENUM('voucher_code','voucher_hint','discount_text') NOT NULL DEFAULT 'voucher_hint',
|
||||
title VARCHAR(160) NOT NULL,
|
||||
code VARCHAR(120) NULL,
|
||||
description TEXT NULL,
|
||||
valid_from DATETIME NULL,
|
||||
valid_until DATETIME NULL,
|
||||
is_public TINYINT(1) NOT NULL DEFAULT 1,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_listing_benefits_listing FOREIGN KEY (listing_id) REFERENCES listings(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_listing_benefits_occurrence FOREIGN KEY (occurrence_id) REFERENCES listing_occurrences(id) ON DELETE CASCADE,
|
||||
INDEX idx_listing_benefits_listing (listing_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Community / Forum
|
||||
CREATE TABLE forum_categories (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user