Class: Cassie::Schema::Migrator
Instance Attribute Summary collapse
-
#after_each ⇒ Object
Returns the value of attribute after_each.
-
#before_each ⇒ Object
Returns the value of attribute before_each.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#current_version ⇒ Object
readonly
Returns the value of attribute current_version.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#target_version ⇒ Object
readonly
Returns the value of attribute target_version.
Instance Method Summary collapse
-
#applied_versions ⇒ Object
versions applied to the database enumerated in most recent first order.
-
#initialize(target) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate ⇒ Object
Constructor Details
#initialize(target) ⇒ Migrator
Returns a new instance of Migrator.
13 14 15 16 17 18 19 20 |
# File 'lib/cassie/schema/migrator.rb', line 13 def initialize(target) @target_version = build_target_version(target) @current_version = Cassie::Schema.version @direction = build_direction @before_each = Proc.new{} @after_each = Proc.new{} @commands = send("build_#{direction}_commands") end |
Instance Attribute Details
#after_each ⇒ Object
Returns the value of attribute after_each.
10 11 12 |
# File 'lib/cassie/schema/migrator.rb', line 10 def after_each @after_each end |
#before_each ⇒ Object
Returns the value of attribute before_each.
10 11 12 |
# File 'lib/cassie/schema/migrator.rb', line 10 def before_each @before_each end |
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
9 10 11 |
# File 'lib/cassie/schema/migrator.rb', line 9 def commands @commands end |
#current_version ⇒ Object (readonly)
Returns the value of attribute current_version.
8 9 10 |
# File 'lib/cassie/schema/migrator.rb', line 8 def current_version @current_version end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
8 9 10 |
# File 'lib/cassie/schema/migrator.rb', line 8 def direction @direction end |
#target_version ⇒ Object (readonly)
Returns the value of attribute target_version.
8 9 10 |
# File 'lib/cassie/schema/migrator.rb', line 8 def target_version @target_version end |
Instance Method Details
#applied_versions ⇒ Object
versions applied to the database enumerated in most recent first order
30 31 32 |
# File 'lib/cassie/schema/migrator.rb', line 30 def applied_versions @applied_versions ||= Cassie::Schema.applied_versions.to_a end |
#migrate ⇒ Object
22 23 24 25 26 |
# File 'lib/cassie/schema/migrator.rb', line 22 def migrate commands_with_callbacks do |command| command.execute end end |