创建表而不在db / migrate rails中指定

时间:2014-02-13 12:45:37

标签: ruby-on-rails ruby ruby-on-rails-3 rails-migrations

我在rails

中有我的article.rb模型的结构
 property :artikelnummer, type: 'string', index: 'not_analyzed'
 property :eannummer, type: 'string', index: 'not_analyzed'

 property :bezeichnung, type: 'multi_field', fields: {
bezeichnung: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'},
suggest: {:type => 'string', :analyzer => 'suggest_analyzer'}
}

  property :bezeichnung_zusatz, type: 'multi_field', fields: {
bezeichnung_zusatz: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
  }

  property :matchcode, type: 'string', index: 'not_analyzed'

  property :mengeneinheit, type: 'string', include_in_all: false

  property :gewicht, type: 'float', include_in_all: false

  property :hersteller, type: 'multi_field', fields: {
hersteller: {type: 'string'},
unchanged: {type: 'string', :index => 'not_analyzed'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
  }

  property :hersteller_nummer, type: 'string', index: 'not_analyzed', include_in_all: false

  property :hersteller_artikelnummer, type: 'string', index: 'not_analyzed'

  property :gruppe, type: 'multi_field', fields: {
gruppe: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
  }

  property :gruppe_zusatz, type: 'multi_field', fields: {
gruppe_zusatz: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
  }

  property :gruppe_nummer, type: 'string', index: 'not_analyzed', include_in_all: false

 #property :hauptgruppe, type: 'multi_field', fields: {
 #  hauptgruppe: {type: 'string'},

#ngram:{:type => 'string',:index_analyzer => 'ngram_index_analyzer',: search_analyzer => 'ngram_search_analyzer'}      #}

 # TODO: n-level facet
  property :hierarchie, type: 'multi_field', fields: {
hierarchie: {type: 'string', index_analyzer: 'hierarchie_index_analyzer', search_analyzer: 'keyword', include_in_all: false},
ngram: {type: 'string', index_analyzer: 'ngram_index_analyzer', search_analyzer: 'ngram_search_analyzer'}
   }

  property :langtext, type: 'multi_field', fields: {
langtext: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
 }

  property :infotext, type: 'multi_field', fields: {
infotext: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
 }

    property :bestelltext, type: 'multi_field', fields: {
bestelltext: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}

}

    property :dimension, type: 'string', include_in_all: false

    property :listenpreis_netto, type: 'float', index: 'not_analyzed', include_in_all: false

   property :listenpreis_brutto, type: 'float', index: 'not_analyzed', include_in_all: false

有没有办法根据上面的信息创建表db / migrations中不存在迁移文件.. 如果是,那么它是如何完成的

提前致谢

编辑 我可以提出的最简单的方法

  

我想在我的数据库中获取上述信息我该怎么做

1 个答案:

答案 0 :(得分:0)

我不熟悉在ActiveRecord中使用Mongo。 (Mongoid?);但我确实使用Mongo使用原始Ruby gem。在Mongo中,没有模式的概念(具有固定的表/列);相当mongo集合和文档在你写这些时就会存在。所以我不确定你对迁移真正做些什么。也许用这些来预先填充收藏品?