Class: Miguel::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/miguel/importer.rb

Overview

Class for importing database schema from Sequel database.

Constant Summary collapse

IGNORED_TABLES =

Which tables we automatically ignore on import.

[ :schema_info ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ Importer

Create new instance for importing schema from given database.



14
15
16
# File 'lib/miguel/importer.rb', line 14

def initialize( db )
  @db = db
end

Instance Attribute Details

#dbObject (readonly)

The database we operate upon.



11
12
13
# File 'lib/miguel/importer.rb', line 11

def db
  @db
end

Instance Method Details

#schemaObject

Import the database schema.



278
279
280
281
282
283
284
285
286
287
288
# File 'lib/miguel/importer.rb', line 278

def schema
  schema = Schema.new

  for name in db.tables
    next if IGNORED_TABLES.include? name
    table = schema.add_table( name )
    import_table( table )
  end

  schema
end