17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/generators/mergration/install/install_generator.rb', line 17
def create_migration_file
files = parse_file
files.each do |file|
file.each do |f|
next unless f[:type] == :entity
@entity = f[:options][:entity]
@attributes = f[:options][:attributes]
@attributes.each do |attribute|
type = attribute[:type]
unless ActiveRecord::ConnectionAdapters::Table.instance_methods.include?(type.to_sym)
raise Mergration::TypeError, "Invalid type '#{type}' is given for #{attribute[:name]}"
end
end
add_mergration_migration(
'create_entity',
table_name: table_name,
entity: entity,
attributes: attributes
)
end
end
end
|