cirandas.net

ref: master

db/migrate/20140507205338_create_search_terms.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class CreateSearchTerms < ActiveRecord::Migration
  def up
    create_table :search_terms do |t|
      t.string      :term
      t.references  :context, :polymorphic => true
      t.string      :asset, :default => 'all'
      t.float       :score, :default => 0
      t.float       :relevance_score, :default => 0
      t.float       :occurrence_score, :default => 0
    end

    add_index :search_terms, :term
    add_index :search_terms, :asset
    add_index :search_terms, :score
    add_index :search_terms, :relevance_score
    add_index :search_terms, :occurrence_score
  end

  def down
    remove_index :search_terms, :term
    remove_index :search_terms, :asset
    remove_index :search_terms, :score
    remove_index :search_terms, :relevance_score
    remove_index :search_terms, :occurrence_score
    drop_table :search_terms
  end
end