Fix migration for MySQL
This commit is contained in:
parent
3bd9b0d62e
commit
d1fbf7b55c
1 changed files with 21 additions and 9 deletions
|
|
@ -23,6 +23,7 @@ class RemovePublicShareVisibilities < ActiveRecord::Migration
|
||||||
end
|
end
|
||||||
|
|
||||||
while index < shareable_size + 100 do
|
while index < shareable_size + 100 do
|
||||||
|
if postgres?
|
||||||
sql = <<-SQL
|
sql = <<-SQL
|
||||||
DELETE
|
DELETE
|
||||||
FROM share_visibilities AS sv
|
FROM share_visibilities AS sv
|
||||||
|
|
@ -32,6 +33,17 @@ class RemovePublicShareVisibilities < ActiveRecord::Migration
|
||||||
AND p.public IS TRUE
|
AND p.public IS TRUE
|
||||||
AND p.id < #{index};
|
AND p.id < #{index};
|
||||||
SQL
|
SQL
|
||||||
|
else
|
||||||
|
sql = <<-SQL
|
||||||
|
DELETE sv
|
||||||
|
FROM share_visibilities AS sv
|
||||||
|
INNER JOIN #{table_name}
|
||||||
|
ON sv.shareable_id = #{table_name}.id
|
||||||
|
WHERE sv.shareable_type = "#{type}"
|
||||||
|
AND #{table_name}.public IS TRUE
|
||||||
|
AND #{table_name}.id < #{index};
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
puts "deleted public share vis up to #{index} of #{type}"
|
puts "deleted public share vis up to #{index} of #{type}"
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue