mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
fix for Postgres: replace " by ', use row['colname'] instead of row[n]
fixes #2277
This commit is contained in:
parent
0639b8e485
commit
be68737572
1 changed files with 9 additions and 9 deletions
|
@ -9,9 +9,9 @@ class AddUserIdToTag < ActiveRecord::Migration[5.2]
|
|||
FROM tags t
|
||||
JOIN taggings tgs ON tgs.tag_id = t.id
|
||||
LEFT OUTER JOIN todos tds
|
||||
ON tgs.taggable_type = "Todo" AND tds.id = tgs.taggable_id
|
||||
ON tgs.taggable_type = 'Todo' AND tds.id = tgs.taggable_id
|
||||
LEFT OUTER JOIN recurring_todos rt
|
||||
ON tgs.taggable_type = "RecurringTodo" AND rt.id = tgs.taggable_id
|
||||
ON tgs.taggable_type = 'RecurringTodo' AND rt.id = tgs.taggable_id
|
||||
WHERE rt.id IS NOT NULL OR tds.id IS NOT NULL
|
||||
GROUP BY t.id, tds.user_id, rt.user_id
|
||||
EOQ
|
||||
|
@ -19,11 +19,11 @@ class AddUserIdToTag < ActiveRecord::Migration[5.2]
|
|||
# Map each tag to the users using it.
|
||||
@tag_users = {}
|
||||
@tags.each do |row|
|
||||
uid = (row[1] ? row[1] : row[2])
|
||||
if not @tag_users[row[0]]
|
||||
@tag_users[row[0]] = [uid]
|
||||
elsif not @tag_users[row[0]].include? uid
|
||||
@tag_users[row[0]] << uid
|
||||
uid = (row['todo_uid'] ? row['todo_uid'] : row['rtodo_uid'])
|
||||
if not @tag_users[row['tid']]
|
||||
@tag_users[row['tid']] = [uid]
|
||||
elsif not @tag_users[row['tid']].include? uid
|
||||
@tag_users[row['tid']] << uid
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ class AddUserIdToTag < ActiveRecord::Migration[5.2]
|
|||
execute <<-EOQ
|
||||
UPDATE taggings ta
|
||||
JOIN todos t
|
||||
ON ta.taggable_type = "Todo" AND t.id = ta.taggable_id
|
||||
ON ta.taggable_type = 'Todo' AND t.id = ta.taggable_id
|
||||
SET ta.tag_id = #{new_tag.id}
|
||||
WHERE t.user_id = #{uid} AND ta.tag_id = #{tid}
|
||||
EOQ
|
||||
|
@ -55,7 +55,7 @@ class AddUserIdToTag < ActiveRecord::Migration[5.2]
|
|||
execute <<-EOQ
|
||||
UPDATE taggings ta
|
||||
JOIN recurring_todos t
|
||||
ON ta.taggable_type = "RecurringTodo" AND t.id = ta.taggable_id
|
||||
ON ta.taggable_type = 'RecurringTodo' AND t.id = ta.taggable_id
|
||||
SET ta.tag_id = #{new_tag.id}
|
||||
WHERE t.user_id = #{uid} AND ta.tag_id = #{tid}
|
||||
EOQ
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue