fix photo share visibilities for the recently migrated
This commit is contained in:
parent
b78ed1b794
commit
75da4e560d
2 changed files with 25 additions and 1 deletions
24
db/migrate/20111023230730_fix_photo_share_visibilities.rb
Normal file
24
db/migrate/20111023230730_fix_photo_share_visibilities.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class FixPhotoShareVisibilities < ActiveRecord::Migration
|
||||
class Photo < ActiveRecord::Base; end
|
||||
|
||||
def self.up
|
||||
raise 'migration currently only compatable with mysql' if postgres?
|
||||
|
||||
if Photo.first.respond_to?(:tmp_old_id)
|
||||
['aspect_visibilities', 'share_visibilities'].each do
|
||||
ActiveRecord::Base.connection.execute <<SQL
|
||||
UPDATE #{vis_table}
|
||||
SET shareable_type='Post'
|
||||
SQL
|
||||
ActiveRecord::Base.connection.execute <<SQL
|
||||
UPDATE #{vis_table}, photos
|
||||
SET #{vis_table}.shareable_type='Photo', #{vis_table}.shareable_id=photo.id
|
||||
WHERE #{vis_table}.shareable_id=photos.tmp_old_id
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20111021184041) do
|
||||
ActiveRecord::Schema.define(:version => 20111023230730) do
|
||||
|
||||
create_table "aspect_memberships", :force => true do |t|
|
||||
t.integer "aspect_id", :null => false
|
||||
|
|
|
|||
Loading…
Reference in a new issue