Sha256: 4778afd91fe494c79aa0b8783dd8d9738b9f7372a02eca72dc5034d2c01ef574

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module RailsConnector
  module Migrations
    # CMS Migrations can alter the structure and content of the CMS and allow
    # other developers to simultaneously apply changes. Migrations provide a set
    # of methods to create, update or delete CMS objects, attributes and object
    # classes.
    #
    # @example Simple Migration
    #
    #   class CreateTestAttribute < RailsConnector::Migrations::Migration
    #     def up
    #       add_attribute_to('homepage', :name => 'test', :type => 'string')
    #     end
    #   end
    class Migration
      include MigrationDsl

      attr_accessor :name
      attr_accessor :version

      def initialize(name, version)
        @name = name
        @version = version.to_i
      end

      def migrate
        announce 'migrating'

        time = Benchmark.measure { up }

        announce 'migrated (%.4fs)' % time.real; puts
      end

      private

      def announce(message)
        text = "#{version} #{name}: #{message}"
        length = [0, 75 - text.length].max
        puts('== %s %s' % [text, '=' * length])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
infopark_cloud_connector-7.1.0 lib/rails_connector/migrations/migration.rb
infopark_cloud_connector-7.0.2 lib/rails_connector/migrations/migration.rb
infopark_cloud_connector-7.0.1 lib/rails_connector/migrations/migration.rb
infopark_cloud_connector-7.0.0 lib/rails_connector/migrations/migration.rb