Class: Syntropy::DB::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/syntropy/db/schema.rb

Defined Under Namespace

Classes: SchemaBlockRunner

Instance Method Summary collapse

Constructor Details

#initialize(module_loader: nil, schema_root: '_schema') ⇒ Schema

Returns a new instance of Schema.



6
7
8
9
10
11
12
# File 'lib/syntropy/db/schema.rb', line 6

def initialize(module_loader: nil, schema_root: '_schema', &)
  @migrations = {}
  @module_loader = module_loader
  @schema_root = schema_root
  load_schema_from_modules if @module_loader
  run_schema_block(&) if block_given?
end

Instance Method Details

#apply(connection_pool) ⇒ Object



14
15
16
# File 'lib/syntropy/db/schema.rb', line 14

def apply(connection_pool)
  execute_migrations(connection_pool)
end

#current_version(connection_pool) ⇒ Object



18
19
20
21
22
# File 'lib/syntropy/db/schema.rb', line 18

def current_version(connection_pool)
  connection_pool.with_db do |db|
    get_schema_version(db)
  end
end