Skip to content

Commit

Permalink
Pass through non-column statements in create_table blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
md5 committed Jun 9, 2016
1 parent 30b2f09 commit 180875f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/schema_plus/core/active_record/schema_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def table(table, _)
,? \s*
(?<options>.*) \s+
do \s* \|t\| \s* $
(?<columns>.*)
(?<statements>.*)
^\s*end\s*$
(?<trailer>.*)
\Z
Expand All @@ -66,17 +66,22 @@ def table(table, _)
env.table.pname = m[:name]
env.table.options = m[:options].strip
env.table.trailer = m[:trailer].split("\n").map(&:strip).reject{|s| s.blank?}
env.table.columns = m[:columns].strip.split("\n").map { |col|
m = col.strip.match %r{
m[:statements].strip.split("\n").each do |statement|
statement.strip!
m = statement.match %r{
^
t\.(?<type>\S+) \s*
[:'"](?<name>[^"\s]+)[,"]? \s*
,? \s*
(?<options>.*)
$
}x
SchemaDump::Table::Column.new name: m[:name], type: m[:type], options: eval("{" + m[:options] + "}"), comments: []
}
if m.nil?
env.table.statements << statement
else
env.table.columns << SchemaDump::Table::Column.new(name: m[:name], type: m[:type], options: eval("{" + m[:options] + "}"), comments: [])
end
end
end
end
end
Expand Down

0 comments on commit 180875f

Please sign in to comment.