SET NAMES utf8mb4;

CREATE TABLE shop_path_aliases (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    shop_id BIGINT UNSIGNED NOT NULL,
    network_id BIGINT UNSIGNED NULL,
    host VARCHAR(255) NOT NULL,
    normalized_host VARCHAR(255) NOT NULL,
    path_prefix VARCHAR(190) NOT NULL,
    is_active 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,
    UNIQUE KEY uq_shop_path_alias_host_prefix (normalized_host, path_prefix),
    INDEX idx_shop_path_alias_shop (shop_id),
    INDEX idx_shop_path_alias_network (network_id),
    CONSTRAINT fk_shop_path_alias_shop FOREIGN KEY (shop_id) REFERENCES shops(id),
    CONSTRAINT fk_shop_path_alias_network FOREIGN KEY (network_id) REFERENCES networks(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Exemples à créer depuis l'administration ou lors du déploiement :
-- ateliercomduroumois.fr/client
-- ateliercomdesfranchises.fr/client
