Module: Stagehand::Schema::DumperExtensions

Defined in:
lib/stagehand/schema/statements.rb

Overview

Allow dumping of stagehand create_table directive e.g. create_table “comments”, stagehand: true do |t|

Instance Method Summary collapse

Instance Method Details

#table(table_name, stream) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/stagehand/schema/statements.rb', line 38

def table(table_name, stream)
  stagehand = Stagehand::Schema.has_stagehand?(table_name)
  stagehand = ':commit_entries' if table_name == Staging::CommitEntry.table_name

  table_stream = StringIO.new
  super(table_name, table_stream)
  table_stream.rewind
  table_schema = table_stream.read.gsub(/create_table (.+) do/, 'create_table \1' + ", stagehand: #{stagehand} do")
  stream.puts table_schema

  return stream
end