10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/enum_table/schema_dumper.rb', line 10
def tables_with_enum_table(stream)
tables_without_enum_table(stream)
table_names = @connection.enum_tables
table_names.each do |table_name|
stream.puts " create_enum_table #{table_name.inspect}, force: true do |t|"
enum_table_column(stream, table_name, 'value', SchemaStatements::DEFAULT_VALUE_ATTRIBUTES)
@connection.execute("SELECT id, value FROM #{@connection.quote_table_name table_name} ORDER BY id").each do |row|
stream.puts " t.add #{row[1].to_s.inspect}, #{row[0]}"
end
stream.puts " end"
stream.puts
end
end
|