A platform for community discussion. Free, open, simple.
FIX: replace model usage with SQL query
Régis Hanolc628166bb4b3
diff --git a/plugins/poll/db/post_migrate/20180820080623_migrate_polls_data.rb b/plugins/poll/db/post_migrate/20180820080623_migrate_polls_data.rbindex 047164f4a51..1cd8b6abae0 100644--- a/plugins/poll/db/post_migrate/20180820080623_migrate_polls_data.rb+++ b/plugins/poll/db/post_migrate/20180820080623_migrate_polls_data.rb@@ -85,7 +85,7 @@ class MigratePollsData < ActiveRecord::Migration[5.2]endr.polls.values.each do |poll|- name = poll["name"].presence || "poll"+ name = escape(poll["name"].presence || "poll")type = POLL_TYPES[(poll["type"].presence || "")[/(regular|multiple|number)/, 1] || "regular"]status = poll["status"] == "open" ? 0 : 1visibility = poll["public"] == "true" ? 1 : 0@@ -95,7 +95,7 @@ class MigratePollsData < ActiveRecord::Migration[5.2]step = poll["step"].to_i.clamp(0, max)anonymous_voters = poll["anonymous_voters"].to_i.clamp(0, PG_INTEGER_MAX)- next if Poll.exists?(post_id: r.post_id, name: escape(name))+ next if DB.query_single("SELECT COUNT(*) FROM polls WHERE post_id = ? AND name = ? LIMIT 1", r.post_id, name).first > 0poll_id = execute(<<~SQLINSERT INTO polls (@@ -113,7 +113,7 @@ class MigratePollsData < ActiveRecord::Migration[5.2]updated_at) VALUES (#{r.post_id},- '#{escape(name)}',+ '#{name}',#{type},#{status},#{visibility},