-- CreateTable
CREATE TABLE `error_logs` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `ref` VARCHAR(32) NOT NULL,
    `code` VARCHAR(64) NOT NULL,
    `category` VARCHAR(32) NOT NULL,
    `http_status` INTEGER NOT NULL,
    `message` TEXT NOT NULL,
    `stack` TEXT NULL,
    `method` VARCHAR(10) NOT NULL,
    `path` VARCHAR(512) NOT NULL,
    `user_id` INTEGER NULL,
    `request_id` VARCHAR(64) NULL,
    `metadata` JSON NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

    UNIQUE INDEX `error_logs_ref_key`(`ref`),
    INDEX `error_logs_code_idx`(`code`),
    INDEX `error_logs_category_idx`(`category`),
    INDEX `error_logs_created_at_idx`(`created_at`),
    INDEX `error_logs_user_id_idx`(`user_id`),
    INDEX `error_logs_path_idx`(`path`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
