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:
authorcmrd Senya <senya@riseup.net>2016-08-22 15:12:35 +0300
committercmrd Senya <senya@riseup.net>2016-11-28 16:56:56 +0300
commit33ad411bbd0d48652d161a60627657f75d467292 (patch)
treefee7d5c6e0ae71f251e83452bf89d12aa1bed725 /db
parentef5751b808f7aa47b1ad10790e1c30894ae67b43 (diff)
Mentions in comments backend changes
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20161107100840_polymorphic_mentions.rb38
-rw-r--r--db/schema.rb11
2 files changed, 44 insertions, 5 deletions
diff --git a/db/migrate/20161107100840_polymorphic_mentions.rb b/db/migrate/20161107100840_polymorphic_mentions.rb
new file mode 100644
index 000000000..07b096394
--- /dev/null
+++ b/db/migrate/20161107100840_polymorphic_mentions.rb
@@ -0,0 +1,38 @@
+class PolymorphicMentions < ActiveRecord::Migration
+ def change
+ remove_index :mentions, column: %i(post_id)
+ remove_index :mentions, column: %i(person_id post_id), unique: true
+ rename_column :mentions, :post_id, :mentions_container_id
+ add_column :mentions, :mentions_container_type, :string, null: false
+ add_index :mentions,
+ %i(mentions_container_id mentions_container_type),
+ name: "index_mentions_on_mc_id_and_mc_type",
+ length: {mentions_container_type: 191}
+ add_index :mentions,
+ %i(person_id mentions_container_id mentions_container_type),
+ name: "index_mentions_on_person_and_mc_id_and_mc_type",
+ length: {mentions_container_type: 191},
+ unique: true
+
+ reversible(&method(:up_down))
+ end
+
+ class Mention < ActiveRecord::Base
+ end
+
+ class Notification < ActiveRecord::Base
+ end
+
+ def up_down(change)
+ change.up do
+ Mention.update_all(mentions_container_type: "Post")
+ Notification.where(type: "Notifications::Mentioned").update_all(type: "Notifications::MentionedInPost")
+ end
+
+ change.down do
+ Notification.where(type: "Notifications::MentionedInPost").update_all(type: "Notifications::Mentioned")
+ Mention.where(mentions_container_type: "Comment").destroy_all
+ Notification.where(type: "Notifications::MentionedInComment").destroy_all
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 402f53db2..7e0e55ec0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161024231443) do
+ActiveRecord::Schema.define(version: 20161107100840) do
create_table "account_deletions", force: :cascade do |t|
t.string "diaspora_handle", limit: 255
@@ -204,13 +204,14 @@ ActiveRecord::Schema.define(version: 20161024231443) do
end
create_table "mentions", force: :cascade do |t|
- t.integer "post_id", limit: 4, null: false
- t.integer "person_id", limit: 4, null: false
+ t.integer "mentions_container_id", limit: 4, null: false
+ t.integer "person_id", limit: 4, null: false
+ t.string "mentions_container_type", limit: 255, null: false
end
- add_index "mentions", ["person_id", "post_id"], name: "index_mentions_on_person_id_and_post_id", unique: true, using: :btree
+ add_index "mentions", ["mentions_container_id", "mentions_container_type"], name: "index_mentions_on_mc_id_and_mc_type", length: {"mentions_container_id"=>nil, "mentions_container_type"=>191}, using: :btree
+ add_index "mentions", ["person_id", "mentions_container_id", "mentions_container_type"], name: "index_mentions_on_person_and_mc_id_and_mc_type", unique: true, length: {"person_id"=>nil, "mentions_container_id"=>nil, "mentions_container_type"=>191}, using: :btree
add_index "mentions", ["person_id"], name: "index_mentions_on_person_id", using: :btree
- add_index "mentions", ["post_id"], name: "index_mentions_on_post_id", using: :btree
create_table "messages", force: :cascade do |t|
t.integer "conversation_id", limit: 4, null: false