[deploy] Cleanup orphan data from buffer_updates (#10365)
* Cleanup orphan data from backup_data and buffer_updates * Remove script as the table has been removed
This commit is contained in:
parent
0ca4e8b371
commit
53deac75cd
1 changed files with 15 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
module DataUpdateScripts
|
||||
class NullifyOrphanRowsFromBufferUpdatesByComposerUserId
|
||||
def run
|
||||
# Nullify all BufferUpdates composer_user_id belonging to Users that don't exist anymore
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<~SQL.squish,
|
||||
UPDATE buffer_updates
|
||||
SET composer_user_id = NULL
|
||||
WHERE composer_user_id IS NOT NULL
|
||||
AND composer_user_id NOT IN (SELECT id FROM users);
|
||||
SQL
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue