Class: PGTrunk::Operations::Tables::CreateTable
- Inherits:
-
PGTrunk::Operation
- Object
- PGTrunk::Operation
- PGTrunk::Operations::Tables::CreateTable
- Defined in:
- lib/pg_trunk/operations/tables/create_table.rb
Overview
When dealing with tables we're only interested in dumping tables one-by-one to enable other operations in between tables.
We doesn't overload the method create_table, but
keep the original implementation unchanged. That's why
neither to_sql, invert or generates_object are necessary.
While we rely on the original implementation, there are some differences in a way we fetching tables and dumping them to the schema:
- we extracting both qualified
nameandoidfor every table, and checking them against the content ofpg_trunk; - we wrap every table new_name this class for dependencies resolving;
- we don't keep indexes and check constraints inside the table definitions because they can depend on functions which, in turn, can depend on tables.
Instance Method Summary collapse
-
#to_ruby ⇒ Object
Instead of defining
ruby_snippet, we overload theto_rubyto rely on the original implementation.
Methods included from PGTrunk::Operation::SQLHelpers
Methods included from PGTrunk::Operation::RubyHelpers
Methods included from PGTrunk::Operation::Inversion
Methods included from PGTrunk::Operation::Validations
Methods included from PGTrunk::Operation::Attributes
Instance Method Details
#to_ruby ⇒ Object
Instead of defining ruby_snippet, we overload
the to_ruby to rely on the original implementation.
We overloaded the ActiveRecord::SchemaDumper
methods indexes_in_create and check_constraints_in_create
so that they do nothing to exclude indexes and constraints
from a table definition.
52 53 54 55 56 |
# File 'lib/pg_trunk/operations/tables/create_table.rb', line 52 def to_ruby stream = StringIO.new PGTrunk.dumper.send(:table, name.lean, stream) unindent(stream.string) end |