migration iterates through shareables
This commit is contained in:
parent
4f7dda6012
commit
8a61718efd
1 changed files with 4 additions and 2 deletions
|
|
@ -11,14 +11,16 @@
|
||||||
|
|
||||||
class RemovePublicShareVisibilities < ActiveRecord::Migration
|
class RemovePublicShareVisibilities < ActiveRecord::Migration
|
||||||
class ShareVisibility < ActiveRecord::Base; end
|
class ShareVisibility < ActiveRecord::Base; end
|
||||||
|
class Post < ActiveRecord::Base; end
|
||||||
|
class Photo < ActiveRecord::Base; end
|
||||||
|
|
||||||
def self.up
|
def self.up
|
||||||
%w{Post Photo}.each do |type|
|
%w{Post Photo}.each do |type|
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
visibilitiy_size = ShareVisibility.count
|
shareable_size = type.constantize.count
|
||||||
|
|
||||||
while index < visibilitiy_size + 100 do
|
while index < shareable_size + 100 do
|
||||||
sql = <<-SQL
|
sql = <<-SQL
|
||||||
DELETE sv
|
DELETE sv
|
||||||
FROM share_visibilities AS sv
|
FROM share_visibilities AS sv
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue