infopark_reactor_migrations
Reactor::Migrations is a Rails 3 gem that makes working with Fiona just as easy as with Rails native migrations. Reactor::Migrations stores it’s versioning information inside CM and thus it is compatible with all backup solutions. Please note the fact, that Reactor cannot account for manual modifications made to the CM (although it gives it’s best)
Disclaimer
The code has been deployed and run for months. It showed itself to be stable and dependable. It may not work for you, although it should.
Installation
config/initializers/reactor.rb: Reactor::Configuration.xml_access =
:host => 'localhost', # Fiona host
:port => 6001, # CM http port (TCL port + 1)
:id => '1234', # leave it as is
:username => 'root', # default user for all requests
:secret => 'MYSECRET' # instance secret!
Example
> rails g cm:migration ExampleMigration
edit cm/migrate/_example_migration.rb …
def self.up
create_attribute :name => "test_attribute", :type => "enum" do
set :values, ["value1", "value2"]
set :title, "test attr"
end
create_class :name => "ExampleClass", :title =>"Beispiel", :type => "publication" do
set :title, {"Beispielvorlage" => {:lang => :de}, "Example obj class" => {:lang => :en}}
take :authors, :mandatory => true # adds existing mandatory ! attribute named "authors"
take :contributors # adds existing attribute named "authors"
take :test_attribute, :preset => "value2" # we just created it!
end
end
def self.down
delete_class :name => 'ExampleClass'
delete_attribute :name => 'test_attribute'
end
… and finally
> rake cm:migrate
You can also type
> rake cm:migrate VERSION=0
to revert any changes (VERSION allows you to migrate to a specific version too).
That’s all! Enjoy!
Copyright © 2011 Tomasz Przedmojski, [email protected], Infopark AG