Sha256: bd1b4dbe877dd7b74ce3557c01c3f03be284a44410b8635d2ff85ed9f0f2545a

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

class <%= class_name %> < ::Scrivito::Migration
  def up
    # This migration file allows to create and modify object class definitions or to change the CMS
    # content programatically. All Scrivito SDK classes and methods are available and arbitrary Ruby
    # code can be executed.
    #
    # Use `bundle exec rake cms:migrate` to run all migrations that are new to the `rtc` workspace.
    # Migrations are identified by an ID and only get executed once. If you migrate the CMS an
    # existing `rtc` workspace is used or a new `rtc` workspace is created. Only one developer at a
    # time can run migrations, which means to quickly try to publish the current migrations.
    #
    # Use `bundle exec rake cms:migrate:publish` to publish your `rtc` workspace that holds the
    # latest unpublished migrations.
    #
    # To get you started, here is a list of the most common SDK methods to alter the CMS content.
    #
    # @example Create a new obj class named "Homepage" of type "publication" that has a "string" attribute named "locale".
    #   Scrivito::ObjClass.create(name: 'Homepage', type: :publication, attributes: [
    #     {name: 'locale', type: :string}
    #   ])
    #
    # @example Find the obj class named "Homepage".
    #   Scrivito::ObjClass.find('Homepage')
    #
    # @example Update the "title" of an obj class named "Homepage".
    #   Scrivito::ObjClass.find('Homepage').update(title: 'Home')
    #
    # @example Add an "enum" attribute named "category" to the obj class named "Homepage".
    #   Scrivito::ObjClass.find('Homepage').attributes.add(name: 'category', type: :enum, values: %w(tech, social))
    #
    # @example Update the "category" attribute and add another value.
    #   attribute = Scrivito::ObjClass.find('Homepage').attributes['category']
    #   attribute.update(values: attribute.values << 'media')
    #
    # @example Destroy the attribute "category" from the obj class "Homepage".
    #   Scrivito::ObjClass.find('Homepage').attributes['category'].destroy
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivito_sdk-0.17.0 lib/generators/cms/migration/templates/migration.erb