Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a unique index on mwpageid and wikiid for non-deleted rows #4381

Merged

Conversation

nateberkopec
Copy link
Contributor

[4] pry(main)> Article.first
[2021-03-12 15:03:57.667 DEBUG] Article Load (0.4ms)  SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` ASC LIMIT 1
=> #<Article:0x00007fd3f775d258
 id: 2,
 title: "Bar/Discussioni/ArtAndFeminism_2018_a_Firenze",
 created_at: Fri, 12 Mar 2021 21:51:10 UTC +00:00,
 updated_at: Fri, 12 Mar 2021 21:51:10 UTC +00:00,
 views_updated_at: nil,
 namespace: 4,
 rating: nil,
 rating_updated_at: nil,
 deleted: false,
 language: nil,
 average_views: nil,
 average_views_updated_at: nil,
 wiki_id: 1,
 mw_page_id: 6887755,
 index_hash: "68877551">
[5] pry(main)> Article.first.update(deleted:true)
[2021-03-12 15:04:08.987 DEBUG] Article Load (0.5ms)  SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` ASC LIMIT 1
[2021-03-12 15:04:08.991 DEBUG]  (0.2ms)  BEGIN
[2021-03-12 15:04:08.991 DEBUG] Article Update (0.3ms)  UPDATE `articles` SET `articles`.`deleted` = TRUE, `articles`.`updated_at` = '2021-03-12 22:04:08' WHERE `articles`.`id` = 2
[2021-03-12 15:04:08.992 DEBUG]  (0.6ms)  COMMIT
=> true
[6] pry(main)> Article.first
[2021-03-12 15:04:11.336 DEBUG] Article Load (0.3ms)  SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` ASC LIMIT 1
=> #<Article:0x00007fd3ef71c350
 id: 2,
 title: "Bar/Discussioni/ArtAndFeminism_2018_a_Firenze",
 created_at: Fri, 12 Mar 2021 21:51:10 UTC +00:00,
 updated_at: Fri, 12 Mar 2021 22:04:08 UTC +00:00,
 views_updated_at: nil,
 namespace: 4,
 rating: nil,
 rating_updated_at: nil,
 deleted: true,
 language: nil,
 average_views: nil,
 average_views_updated_at: nil,
 wiki_id: 1,
 mw_page_id: 6887755,
 index_hash: nil>

@@ -47,6 +47,8 @@
t.date "average_views_updated_at"
t.integer "wiki_id"
t.integer "mw_page_id"
t.virtual "index_hash", type: :string, as: "if(`deleted`,NULL,concat(`mw_page_id`,`wiki_id`))", stored: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for this work on mariadb 10.2 and lesser, this column must be stored

@ragesoss
Copy link
Member

It took a while, but I've cleared out all the violations of this constraint.

@ragesoss ragesoss merged commit efb0e1f into WikiEducationFoundation:master Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants