Sha256: 2d0f3c722ac848eefd175d5e569c7b35cb81dc439e77992be35fe1c252850957

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

class RecordModelMigration < Migration
  def self.up(site)
    records = Model.new(site, name: 'Record')
    records.modify do |records|
      # identity, hierarchy and search
      add_many  :children, model: :record, foreign_key: 'parent', order: 'index asc', display: false
      add_field :index, :integer, validations: {required: {}}, display: false
      add_one   :owner, model: :user, display: false
      add_field :name, :string
      add_field :show_in_search, :boolean, default: true, section: 'Options'
      add_field :search_keywords, :array, of: :string, display: false
      add_field :search_title, :alias, of: :name, display: false

      # modelling
      add_one   :eigenmodel, model: :model, destroy: true, display: false
      add_one   :parent, model: :record, index: true, display: false
      add_one   :model, index: true, display: false
      records.descendants = [records]
    end

    site.model_types['records'] = records.id
    site.model_plural_names['Record'] = 'records'
    site.save
  end
  
  def self.down(site)
    site.records.destroy
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
yodel-0.0.7 lib/yodel/models/migrations/01_record_model.rb
yodel_production_environment-0.0.7 lib/migrations/yodel/01_record_model.rb
yodel_development_environment-0.0.7 lib/migrations/yodel/01_record_model.rb
yodel-0.0.4 lib/yodel/models/migrations/01_record_model.rb
yodel-0.0.3 lib/yodel/models/migrations/01_record_model.rb
yodel-0.0.2 lib/yodel/models/migrations/01_record_model.rb