ALTER TABLE entity_translate_jobs
    MODIFY COLUMN entity_type ENUM(
        'tag','category','album_tag','album_category',
        'performer','channel','album_performer','album_channel',
        'video','album','page'
    ) NOT NULL;

ALTER TABLE entity_translate_jobs
    MODIFY COLUMN status ENUM('pending','processing','paused','completed','failed','cancelled') NOT NULL DEFAULT 'pending';

ALTER TABLE entity_translate_jobs ADD COLUMN scope VARCHAR(8) NOT NULL DEFAULT 'ids' AFTER entity_type;
ALTER TABLE entity_translate_jobs ADD COLUMN type_filter VARCHAR(16) NOT NULL DEFAULT '' AFTER scope;
ALTER TABLE entity_translate_jobs ADD COLUMN fields_json TEXT DEFAULT NULL AFTER languages;
ALTER TABLE entity_translate_jobs ADD COLUMN cursor_id INT UNSIGNED NOT NULL DEFAULT 0 AFTER attempt_map;
ALTER TABLE entity_translate_jobs ADD COLUMN batch_seq INT UNSIGNED NOT NULL DEFAULT 0 AFTER cursor_id;
ALTER TABLE entity_translate_jobs ADD COLUMN charged_credits DECIMAL(12,4) NOT NULL DEFAULT 0 AFTER credits_debited;
ALTER TABLE entity_translate_jobs ADD COLUMN pause_reason VARCHAR(191) DEFAULT NULL AFTER error_message;

ALTER TABLE entity_translate_jobs ADD INDEX idx_type_status (entity_type, status);

INSERT IGNORE INTO settings (setting_key, setting_value, autoload) VALUES
('entity_autotranslate_album', '0', 1),
('entity_autotranslate_album_channel', '0', 1),
('entity_autotranslate_album_performer', '0', 1),
('entity_autotranslate_channel', '0', 1),
('entity_autotranslate_page', '0', 1),
('entity_autotranslate_performer', '0', 1),
('entity_autotranslate_video', '0', 1);
