Sha256: dc6dc026e65df24b9c8a0f0347a185091c6944eea725c3cdc5ddd4c4cc996843

Contents?: true

Size: 1.7 KB

Versions: 6

Compression:

Stored size: 1.7 KB

Contents

class BitPlayer::Tool < ActiveRecord::Base; end
class BitPlayer::ContentModule < ActiveRecord::Base; end
class BitPlayer::ContentProvider < ActiveRecord::Base; end
class BitPlayer::ContentProviders::SlideshowProvider < BitPlayer::ContentProvider; end

class ConvertToolsModulesPresentersToBitCore < ActiveRecord::Migration
  def up
    BitPlayer::Tool.all.each do |tool|
      BitCore::Tool.create!(
        id: tool.id,
        title: tool.title,
        position: tool.position
      )
    end
    BitPlayer::ContentModule.all.each do |mod|
      BitCore::ContentModule.create!(
        id: mod.id,
        title: mod.title,
        bit_core_tool_id: mod.bit_player_tool_id,
        position: mod.position
      )
    end
    BitPlayer::ContentProvider.all.each do |pro|
      type = pro.type
      if type == "BitPlayer::ContentProviders::SlideshowProvider"
        type = "BitCore::ContentProviders::SlideshowProvider"
      end
      BitCore::ContentProvider.create!(
        id: pro.id,
        type: type,
        show_next_nav: (type == "BitCore::ContentProviders::SlideshowProvider" ? true : pro.show_nav_link?),
        source_content_type: pro.source_content_type,
        source_content_id: pro.source_content_id,
        bit_core_content_module_id: pro.bit_player_content_module_id,
        position: pro.position
      )
    end
    execute <<-SQL
      ALTER TABLE bit_player_content_modules
        DROP CONSTRAINT IF EXISTS fk_content_modules_tools
    SQL
    execute <<-SQL
      ALTER TABLE bit_player_content_providers
        DROP CONSTRAINT IF EXISTS fk_content_providers_modules
    SQL
    drop_table :bit_player_tools
    drop_table :bit_player_content_modules
    drop_table :bit_player_content_providers
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bit_player-0.4.10 db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb
bit_player-0.4.9 db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb
bit_player-0.5.0 db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb
bit_player-0.4.4 db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb
bit_player-0.4.3 db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb
bit_player-0.4.2 db/migrate/20140620222851_convert_tools_modules_presenters_to_bit_core.rb