Sha256: b5c5d893c1b54fbefdec93732e26ff95df8a2b61bffcd390994471d339713542

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

# Dummy class to declare the model before droping
class CacheInformation < ActiveRecord::Base

end

class DropCacheInformationTable < ActiveRecord::Migration
  def self.up
    # On 99.9% existing blogs, cache will be installed in public/
    # That means we first need to wipe existing files or they will be served
    # And the cache will never be accessed
    list = CacheInformation.find(:all)
    
    list.each do |file|
      path = File.join(RAILS_ROOT, 'public', file.path)
      if File.exist?(path)
        FileUtils.rm(path)
      end
    end
    
    drop_table :cache_informations
  end

  def self.down
    create_table :cache_informations do |t|
      t.string :path
      t.timestamps
    end
    # Add index on path because there are validates_uniqueness on it
    add_index :cache_informations, :path
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typo-5.5 db/migrate/089_drop_cache_information_table.rb