CREATE TABLE IF NOT EXISTS stock_sedes (
    id INT AUTO_INCREMENT PRIMARY KEY,
    product_id INT NOT NULL,
    sede_id INT NOT NULL,
    quantity INT NOT NULL DEFAULT 0,
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE,
    FOREIGN KEY (sede_id) REFERENCES sedes(id) ON DELETE CASCADE,
    UNIQUE KEY `product_sede` (`product_id`, `sede_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
