Sha256: 2cdfd4f6362ec8c3155580268aacdb6b1e2f20c405dd3be85e0bd3f0a0eb1a07

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 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, :string, 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

7 entries across 7 versions & 3 rubygems

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