CREATE TABLE /*_*/cx_translations (
    -- translation id. Autogenerated.
    translation_id int primary key auto_increment,
    -- Source title of the translation
    translation_source_title varbinary(512) not null,
    -- Target title of the translation
    translation_target_title varbinary(512) not null,
    -- Source language. language code
    translation_source_language varbinary(36) not null,
    -- Target language. language code
    translation_target_language varbinary(36) not null,
    -- Revision id of source article
    translation_source_revision_id int unsigned,
    -- Revision id of published translation
    translation_target_revision_id int unsigned,
    -- source of the page as full canonical url -- https://www.mediawiki.org/wiki/Help:CxIsPage
    translation_source_url text binary not null,
    -- link to the draft/published target
    translation_target_url text binary default null,
    -- Status of translation - Draft or published status.
    -- There is no final status. A published translation can be draft again to update again
    translation_status enum('draft', 'published', 'deleted') default null,
    -- Start date of this translation
    translation_start_timestamp varchar(14) binary not null,
    -- Last updated date of this translation
    translation_last_updated_timestamp varchar(14) binary not null,
    -- Progress of the translation - json dump
    translation_progress TINYBLOB not null,
    -- Who started this translation? User id
    translation_started_by int,
    -- Who did the last translation? It need not be the translator who started.
    translation_last_update_by int,
    -- Field to indicate which version of CX
    translation_cx_version tinyint unsigned default 1
) /*$wgDBTableOptions*/;

CREATE UNIQUE INDEX /*i*/cx_translation_ref ON /*_*/cx_translations (
    translation_source_title,
    translation_source_language,
    translation_target_language,
    translation_started_by
);

CREATE INDEX /*i*/cx_translation_languages ON /*_*/cx_translations (
    translation_source_language,
    translation_target_language,
    translation_status
);
