Conversation
`rex_article_slice` and `rex_article_slice_history` reference `rex_article_translation` via `(article_id, language_id)`, its primary key: a slice belongs to one article in one language, which is exactly what a translation row is. Both cascade on delete and restrict on update — an auto increment id never changes, so a cascade on update would only silently rewrite rows in the case that something went wrong. That makes the manual cleanups redundant, which are dropped: `LanguageHandler::delete()` deleted the slices of the language by hand, `ArticleHandler::_deleteArticle()` the slices of the article. The history was cleaned up by neither, so deleting an article or a language left its snapshots behind forever — the cascade fixes that. The index `find_slices` swaps its columns to `(article_id, language_id)` so the foreign key can use it instead of making InnoDB add one of its own. `snapshot` already starts with the two columns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The slices were the last core tables left without a foreign key, after the structure and media pool restructuring (#6667, #6668, #6670, #6671) covered everything else.
Schema
rex_article_sliceandrex_article_slice_historyreferencerex_article_translationvia(article_id, language_id), its primary key. A slice belongs to one article in one language, which is exactly what a translation row is — referencingrex_articleandrex_languageseparately would allow a slice for a language the article does not exist in.ON DELETE CASCADEandON UPDATE RESTRICT: an auto increment id never changes, so a cascade on update would only silently rewrite rows in the case that something went wrong.find_slicesswaps its columns to(article_id, language_id)so the foreign key can use it instead of making InnoDB add an index of its own.snapshotalready starts with the two columns.Handlers
LanguageHandler::delete()deleted the slices of the language by hand,ArticleHandler::_deleteArticle()the slices of the article. Both are redundant now and are dropped.ArticleSliceTestcreates the article and its translation its slices hang off, and lets the cascade clean up.Notes
(article_id, language_id)has no row inrex_article_translation, thenmigrateadds the foreign keys.