Sha256: ef94d444d679725e9b166c652eae7fcee22c85a5bae9ad739a156e1e5198648a

Contents?: true

Size: 813 Bytes

Versions: 108

Compression:

Stored size: 813 Bytes

Contents

class ChangePostElementsToVersions < ActiveRecord::Migration
  def up
    rename_column :pulitzer_content_elements, :post_id, :version_id
    rename_column :pulitzer_post_tags, :post_id, :version_id
    Pulitzer::ContentElement.reset_column_information
    Pulitzer::PostTag.reset_column_information

    # Clone post content elements and clone tags, and assign them to the new version
    Pulitzer::Post.find_each do |post|
      version = post.create_preview_version
      Pulitzer::ContentElement.where(version_id: post.id).update_all(version_id: version.id)
      Pulitzer::PostTag.where(version_id: post.id).update_all(version_id: version.id)
    end
  end

  def down
    rename_column :pulitzer_content_elements, :version_id, :post_id
    rename_column :pulitzer_post_tags, :version_id, :post_id
  end
end

Version data entries

108 entries across 106 versions & 1 rubygems

Version Path
pulitzer-0.15.31 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.30 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.29 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.28 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.27 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.26 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.25 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.24 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.23 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.22 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.21 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.20 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.19 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.18 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.17 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.16 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.15 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.14 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.13 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.12 db/migrate/20151029220558_change_post_elements_to_versions.rb