Class: ROM::SQL::Migration::Migrator Private
- Inherits:
-
Object
- Object
- ROM::SQL::Migration::Migrator
- Extended by:
- Initializer
- Defined in:
- lib/rom/sql/migration/migrator.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- DEFAULT_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'db/migrate'.freeze
- VERSION_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'%Y%m%d%H%M%S'.freeze
Instance Method Summary collapse
- #create_file(name, version = generate_version) ⇒ Object private
- #generate_version ⇒ Object private
- #migration(&block) ⇒ Object private
- #migration_file_content ⇒ Object private
- #pending? ⇒ Boolean private
- #run(options = {}) ⇒ Object private
Instance Method Details
#create_file(name, version = generate_version) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rom/sql/migration/migrator.rb', line 36 def create_file(name, version = generate_version) filename = "#{version}_#{name}.rb" dirname = Pathname(path) fullpath = dirname.join(filename) FileUtils.mkdir_p(dirname) File.write(fullpath, migration_file_content) fullpath end |
#generate_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/rom/sql/migration/migrator.rb', line 48 def generate_version Time.now.utc.strftime(VERSION_FORMAT) end |
#migration(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/rom/sql/migration/migrator.rb', line 31 def migration(&block) Sequel.migration(&block) end |
#migration_file_content ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/rom/sql/migration/migrator.rb', line 53 def migration_file_content File.read(Pathname(__FILE__).dirname.join('template.rb').realpath) end |
#pending? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/rom/sql/migration/migrator.rb', line 26 def pending? !Sequel::Migrator.is_current?(connection, path.to_s) end |
#run(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/rom/sql/migration/migrator.rb', line 21 def run( = {}) Sequel::Migrator.run(connection, path.to_s, ) end |