Class: DbSchema::Normalizer
- Inherits:
-
Object
- Object
- DbSchema::Normalizer
- Defined in:
- lib/db_schema/normalizer.rb
Defined Under Namespace
Classes: Table
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#initialize(schema, connection) ⇒ Normalizer
constructor
A new instance of Normalizer.
- #normalize_tables ⇒ Object
Constructor Details
#initialize(schema, connection) ⇒ Normalizer
7 8 9 10 |
# File 'lib/db_schema/normalizer.rb', line 7 def initialize(schema, connection) @schema = schema @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/db_schema/normalizer.rb', line 5 def connection @connection end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
5 6 7 |
# File 'lib/db_schema/normalizer.rb', line 5 def schema @schema end |
Instance Method Details
#normalize_tables ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/db_schema/normalizer.rb', line 12 def normalize_tables connection.transaction do create_extensions! create_enums! schema.tables = schema.tables.map do |table| if table.has_expressions? Table.new(table, hash, schema.enums.map(&:name), connection).normalized_table else table end end raise Sequel::Rollback end end |