module ContentfulModel::Migrations::Migration

Content Type Migration methods

Public Instance Methods

add_content_type_field(content_type_id, name, type) { |field| ... } click to toggle source
# File lib/contentful_model/migrations/migration.rb, line 12
def add_content_type_field(content_type_id, name, type, &_block)
  content_type = ContentfulModel::Migrations::ContentTypeFactory.find(content_type_id)
  field = content_type.field(name, type)

  yield(field) if block_given?

  content_type.save.publish
end
create_content_type(name, fields = {}, &block) click to toggle source
# File lib/contentful_model/migrations/migration.rb, line 8
def create_content_type(name, fields = {}, &block)
  ContentfulModel::Migrations::ContentTypeFactory.create(name, fields, &block)
end
remove_content_type_field(content_type_id, field_id) click to toggle source
# File lib/contentful_model/migrations/migration.rb, line 21
def remove_content_type_field(content_type_id, field_id)
  content_type = ContentfulModel::Migrations::ContentTypeFactory.find(content_type_id)

  content_type.remove_field(field_id)

  content_type.save.publish
end