Class: XMigra::Migration
Constant Summary collapse
- EMPTY_DB =
'empty database'- FOLLOWS =
'starting from'- CHANGES =
'changes'
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#follows ⇒ Object
readonly
Returns the value of attribute follows.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(info) ⇒ Migration
constructor
A new instance of Migration.
- #reversion ⇒ Object
- #schema_dir ⇒ Object
- #sql ⇒ Object
Constructor Details
#initialize(info) ⇒ Migration
Returns a new instance of Migration.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xmigra/migration.rb', line 11 def initialize(info) @id = info['id'].dup.freeze _follows = info[FOLLOWS] @follows = (_follows.dup.freeze unless _follows == EMPTY_DB) @sql = info.has_key?('sql') ? info["sql"].dup.freeze : nil @description = info["description"].dup.freeze @changes = (info[CHANGES] || []).dup.freeze @changes.each {|c| c.freeze} @all_info = Marshal.load(Marshal.dump(info)) end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
22 23 24 |
# File 'lib/xmigra/migration.rb', line 22 def changes @changes end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
22 23 24 |
# File 'lib/xmigra/migration.rb', line 22 def description @description end |
#file_path ⇒ Object
Returns the value of attribute file_path.
23 24 25 |
# File 'lib/xmigra/migration.rb', line 23 def file_path @file_path end |
#follows ⇒ Object (readonly)
Returns the value of attribute follows.
22 23 24 |
# File 'lib/xmigra/migration.rb', line 22 def follows @follows end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/xmigra/migration.rb', line 22 def id @id end |
Class Method Details
.id_from_filename(fname) ⇒ Object
51 52 53 |
# File 'lib/xmigra/migration.rb', line 51 def id_from_filename(fname) XMigra.secure_digest(fname.upcase) # Base64 encoded digest end |
Instance Method Details
#reversion ⇒ Object
45 46 47 48 |
# File 'lib/xmigra/migration.rb', line 45 def reversion result = RevertFile.new(self) return result if result.exist? end |
#schema_dir ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/xmigra/migration.rb', line 25 def schema_dir @schema_dir ||= begin result = Pathname(file_path).dirname while result.basename.to_s != SchemaManipulator::STRUCTURE_SUBDIR result = result.dirname end result.join('..') end end |
#sql ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/xmigra/migration.rb', line 35 def sql if Plugin.active (@sql || "").dup.tap do |result| Plugin.active.amend_source_sql(result) end else @sql end end |