CREATE TABLE IF NOT EXISTS emotion_museum.api_endpoint (
    id              VARCHAR(64) PRIMARY KEY,
    path            VARCHAR(500) NOT NULL,
    method          VARCHAR(10) NOT NULL,
    operation_id    VARCHAR(200),
    summary         VARCHAR(500),
    description     TEXT,
    tags            VARCHAR(500),
    deprecated      TINYINT(1) DEFAULT 0,
    request_schema  JSON,
    response_schema JSON,
    create_by       VARCHAR(64),
    create_time     DATETIME DEFAULT CURRENT_TIMESTAMP,
    update_by       VARCHAR(64),
    update_time     DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    is_deleted      TINYINT(1) DEFAULT 0,
    remarks         VARCHAR(500),
    UNIQUE INDEX idx_operation_id (operation_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS emotion_museum.api_param (
    id              VARCHAR(64) PRIMARY KEY,
    endpoint_id     VARCHAR(64) NOT NULL,
    param_type      VARCHAR(20) NOT NULL,
    name            VARCHAR(100) NOT NULL,
    required        TINYINT(1) DEFAULT 0,
    param_type_def  VARCHAR(50),
    description     VARCHAR(500),
    default_value   VARCHAR(200),
    enum_values     JSON,
    example         VARCHAR(500),
    INDEX idx_endpoint (endpoint_id),
    FOREIGN KEY (endpoint_id) REFERENCES emotion_museum.api_endpoint(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
