Class: Pakyow::Data::Adapters::Sql::Runner Private
- Inherits:
-
Object
- Object
- Pakyow::Data::Adapters::Sql::Runner
- Defined in:
- lib/pakyow/data/adapters/sql/runner.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.
Instance Method Summary collapse
- #disconnect! ⇒ Object private
-
#initialize(connection, migration_path) ⇒ Runner
constructor
private
A new instance of Runner.
- #run! ⇒ Object private
Constructor Details
#initialize(connection, migration_path) ⇒ Runner
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.
Returns a new instance of Runner.
9 10 11 |
# File 'lib/pakyow/data/adapters/sql/runner.rb', line 9 def initialize(connection, migration_path) @connection, @migration_path = connection, migration_path end |
Instance Method Details
#disconnect! ⇒ 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.
13 14 15 |
# File 'lib/pakyow/data/adapters/sql/runner.rb', line 13 def disconnect! @connection.disconnect end |
#run! ⇒ 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.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pakyow/data/adapters/sql/runner.rb', line 17 def run! Pakyow.module_eval do unless singleton_class.instance_methods.include?(:migration) def self.migration(&block) Sequel.migration(&block) end end end # Allows migrations to be defined with the nice mapping, then executed with the Sequel type. # local_types = @connection.types @connection.adapter.connection.define_singleton_method :type_literal do |column| if column[:type].is_a?(Symbol) begin column[:type] = Data::Types.type_for(column[:type], local_types).[:database_type] rescue Pakyow::UnknownType end end super(column) end Sequel.extension :migration Sequel::Migrator.run( @connection.adapter.connection, @migration_path, allow_missing_migration_files: true ) end |