mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Use heredoc SQL blocks in AddFromAccountIdToNotifications
migration (#26178)
This commit is contained in:
parent
8ac5a93a7d
commit
a2dca50ef3
@ -4,10 +4,39 @@ class AddFromAccountIdToNotifications < ActiveRecord::Migration[5.0]
|
|||||||
def up
|
def up
|
||||||
add_column :notifications, :from_account_id, :integer
|
add_column :notifications, :from_account_id, :integer
|
||||||
|
|
||||||
Notification.where(from_account_id: nil).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(from_account_id: nil).where(activity_type: 'Status').update_all(<<~SQL.squish)
|
||||||
Notification.where(from_account_id: nil).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)')
|
from_account_id = (
|
||||||
Notification.where(from_account_id: nil).where(activity_type: 'Favourite').update_all('from_account_id = (SELECT favourites.account_id FROM notifications AS notifications1 INNER JOIN favourites ON notifications1.activity_id = favourites.id WHERE notifications1.activity_type = \'Favourite\' AND notifications1.id = notifications.id)')
|
SELECT statuses.account_id
|
||||||
Notification.where(from_account_id: nil).where(activity_type: 'Follow').update_all('from_account_id = (SELECT follows.account_id FROM notifications AS notifications1 INNER JOIN follows ON notifications1.activity_id = follows.id WHERE notifications1.activity_type = \'Follow\' AND notifications1.id = notifications.id)')
|
FROM notifications AS notifications1
|
||||||
|
INNER JOIN statuses ON notifications1.activity_id = statuses.id
|
||||||
|
WHERE notifications1.activity_type = 'Status' AND notifications1.id = notifications.id
|
||||||
|
)
|
||||||
|
SQL
|
||||||
|
Notification.where(from_account_id: nil).where(activity_type: 'Mention').update_all(<<~SQL.squish)
|
||||||
|
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
|
||||||
|
)
|
||||||
|
SQL
|
||||||
|
Notification.where(from_account_id: nil).where(activity_type: 'Favourite').update_all(<<~SQL.squish)
|
||||||
|
from_account_id = (
|
||||||
|
SELECT favourites.account_id
|
||||||
|
FROM notifications AS notifications1
|
||||||
|
INNER JOIN favourites ON notifications1.activity_id = favourites.id
|
||||||
|
WHERE notifications1.activity_type = 'Favourite' AND notifications1.id = notifications.id
|
||||||
|
)
|
||||||
|
SQL
|
||||||
|
Notification.where(from_account_id: nil).where(activity_type: 'Follow').update_all(<<~SQL.squish)
|
||||||
|
from_account_id = (
|
||||||
|
SELECT follows.account_id
|
||||||
|
FROM notifications AS notifications1
|
||||||
|
INNER JOIN follows ON notifications1.activity_id = follows.id
|
||||||
|
WHERE notifications1.activity_type = 'Follow' AND notifications1.id = notifications.id
|
||||||
|
)
|
||||||
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
Loading…
Reference in New Issue
Block a user