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.11 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.10 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.9 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.8 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.7 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.6 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.5 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.4 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.3 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.2 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.1 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.15.0 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.14.4 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.14.3 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.14.2 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.14.1 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.14.0 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.13.1 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.12.5 db/migrate/20151029220558_change_post_elements_to_versions.rb
pulitzer-0.13.0 db/migrate/20151029220558_change_post_elements_to_versions.rb