Page MenuHomePhabricator

Add primary key for database table cx_suggestions
Open, In Progress, MediumPublic

Description

The table cx_suggestions does not have a primary key or a unique index.

Please add a primary key as best practice by choosing one or more relevant columns which must be unique by functional or add a new column with an autoincrement value as surrogate key.

Current schema
CREATE TABLE /*_*/cx_suggestions (
    -- Foreign key to cxl_id
    cxs_list_id int NOT NULL,
    -- Source language code
    cxs_source_language varbinary(36) NOT NULL,
    -- Target language code
    cxs_target_language varbinary(36),
    -- Title of the suggestion
    cxs_title varbinary(512) NOT NULL
) /*$wgDBTableOptions*/;

CREATE INDEX /*i*/cx_suggestions_by_lang ON /*_*/cx_suggestions (
    cxs_list_id,
    cxs_source_language,
    cxs_target_language
);

Primary key helps on database maintenance and it can make deletions on the table easier and avoid deadlocks with other deletion or inserts

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

Nikerabbit triaged this task as Medium priority.Aug 1 2022, 11:32 AM
Nikerabbit moved this task from Needs Triage to Enhancements on the ContentTranslation board.

Change 828018 had a related patch set uploaded (by Diesel kapasule; author: Diesel kapasule):

[mediawiki/extensions/ContentTranslation@master] Add cxs_list_id as primary key to table cx_suggestions

https://gerrit.wikimedia.org/r/828018

Diesel_kapasule changed the task status from Open to In Progress.Aug 30 2022, 3:17 PM
Diesel_kapasule claimed this task.

Change 830110 had a related patch set uploaded (by Diesel kapasule; author: Diesel kapasule):

[mediawiki/extensions/ContentTranslation@master] schema: Add new column cxs_id and convert it to primary key

https://gerrit.wikimedia.org/r/830110

Change 828018 abandoned by Diesel kapasule:

[mediawiki/extensions/ContentTranslation@master] Add cxs_list_id as primary key to table cx_suggestions

Reason:

https://gerrit.wikimedia.org/r/828018

Change 830110 abandoned by Nikerabbit:

[mediawiki/extensions/ContentTranslation@master] schema: Add new column cxs_id and convert it to primary key

Reason:

We are planning to drop this table in the future, so it does not make sense to do a schema change for it.

https://gerrit.wikimedia.org/r/830110