Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2017-08-24 23:24:06 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2017-08-26 04:08:37 +0300
commitb040f85790c61a4155a044f3f1fa198e49a96925 (patch)
treed297a6f8c5012860259fb11a979b50d003c268a9 /db
parent0f771dbb107045d78c3f9e01efcc20c232b3ff04 (diff)
Remove root_guid from reshares when post is deleted
And cleanup old reshares with deleted root posts closes #7578
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb b/db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb
new file mode 100644
index 000000000..7a93cca9d
--- /dev/null
+++ b/db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb
@@ -0,0 +1,9 @@
+class CleanupRootGuidsFromReshares < ActiveRecord::Migration[5.1]
+ def up
+ # rubocop:disable Rails/SkipsModelValidations
+ Reshare.joins("LEFT OUTER JOIN posts as root ON root.guid = posts.root_guid")
+ .where("root.id is NULL AND posts.root_guid is NOT NULL")
+ .update_all(root_guid: nil)
+ # rubocop:enable Rails/SkipsModelValidations
+ end
+end