From b14b5e3b448eafa1489d6fe4b702621e25dff1ae Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 3 Dec 2016 20:04:19 +0100 Subject: Improve notification model --- db/migrate/20161203164520_add_from_account_id_to_notifications.rb | 2 +- db/schema.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20161203164520_add_from_account_id_to_notifications.rb b/db/migrate/20161203164520_add_from_account_id_to_notifications.rb index 295f95599..282676760 100644 --- a/db/migrate/20161203164520_add_from_account_id_to_notifications.rb +++ b/db/migrate/20161203164520_add_from_account_id_to_notifications.rb @@ -1,6 +1,6 @@ class AddFromAccountIdToNotifications < ActiveRecord::Migration[5.0] def up - add_column :notifications, :from_account_id, :integer, null: false, default: 1 + add_column :notifications, :from_account_id, :integer Notification.where(activity_type: 'Status').update_all('from_account_id = (SELECT statuses.account_id FROM notifications AS notifications1 INNER JOIN statuses ON notifications1.activity_id = statuses.id WHERE notifications1.activity_type = \'Status\' AND notifications1.id = notifications.id)') Notification.where(activity_type: 'Mention').update_all('from_account_id = (SELECT statuses.account_id FROM notifications AS notifications1 INNER JOIN mentions ON notifications1.activity_id = mentions.id INNER JOIN statuses ON mentions.status_id = statuses.id WHERE notifications1.activity_type = \'Mention\' AND notifications1.id = notifications.id)') diff --git a/db/schema.rb b/db/schema.rb index c9676ca40..8e5c806d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -100,9 +100,9 @@ ActiveRecord::Schema.define(version: 20161203164520) do t.integer "account_id" t.integer "activity_id" t.string "activity_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "from_account_id", default: 1, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "from_account_id" t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true, using: :btree end -- cgit