Sha256: 56d142bc55f869fc3e4824e190ae45065e08d3b2d6ec043149bd8c58eedc96a2

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

class CleanupContentsTable < ActiveRecord::Migration
  def self.up
    if adapter_name == 'PostgreSQL'
      indexes(:contents).each do |index|
        if index.name =~ /article_id/
          remove_index(:contents, :name => index.name)
        end
      end
    else
      remove_index :contents, :article_id rescue nil
    end

    remove_column :contents, :article_id rescue nil
    remove_column :contents, :email 
    remove_column :contents, :url
    remove_column :contents, :ip
    remove_column :contents, :blog_name
    remove_column :contents, :status_confirmed

    add_index :contents, :published
    add_index :contents, :text_filter_id
  end

  def self.down
    remove_index :contents, :published
    remove_index :contents, :text_filter_id

    add_column :contents, :article_id, :integer
    add_column :contents, :email, :string
    add_column :contents, :url, :string
    add_column :contents, :ip, :string, :limit => 40
    add_column :contents, :blog_name, :string
    add_column :contents, :status_confirmed, :boolean

    add_index :contents, :article_id
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typo-5.5 db/migrate/060_cleanup_contents_table.rb
typo-5.4.4 db/migrate/060_cleanup_contents_table.rb
typo-5.4.3 db/migrate/060_cleanup_contents_table.rb
typo-5.4.2 db/migrate/060_cleanup_contents_table.rb
typo-5.4.1 db/migrate/060_cleanup_contents_table.rb
typo-5.4 db/migrate/060_cleanup_contents_table.rb