Module: Sequel::Redshift::SchemaDumper
- Includes:
- SchemaDumper
- Defined in:
- lib/sequel/extensions/redshift_schema_dumper.rb
Instance Method Summary collapse
Instance Method Details
#dump_table_schema(table, options = OPTS) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/sequel/extensions/redshift_schema_dumper.rb', line 8 def dump_table_schema(table, =OPTS) gen = dump_table_generator(table, ) commands = [gen.dump_columns, gen.dump_constraints, gen.dump_indexes].reject { |x| x == '' }.join("\n\n") "create_table(#{table.inspect}#{table_options(table, gen, options)}) do\n#{commands.gsub(/^/o, ' ')}\nend" end |
#table_options(table, gen, options) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/sequel/extensions/redshift_schema_dumper.rb', line 15 def (table, gen, ) s = {distkey: table_distkey(table), sortkeys: table_sortkeys(table), sortstyle: table_sortstyle(table), ignore_index_errors: (![:same_db] && [:indexes] != false && !gen.indexes.empty?) }.select { |_,v| v }.inspect[1...-1] s.empty? ? s : ", #{s}" end |