8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/generators/ask_it/install_generator.rb', line 8
def copy_migration
timestamp_number = Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
migration_files = [{ new_file_name: 'create_survey', origin_file_name: 'migration' },
{ new_file_name: 'create_sections', origin_file_name: 'migration_section' },
{ new_file_name: 'update_survey_tables',
origin_file_name: 'migration_update_survey_tables' },
{ new_file_name: 'add_types_to_questions_and_options',
origin_file_name: 'migration_add_types_to_questions_and_options' },
{ new_file_name: 'add_head_number_to_options_table',
origin_file_name: 'migration_add_head_number_to_options_table' },
{ new_file_name: 'create_predefined_values_table',
origin_file_name: 'migration_create_predefined_values_table' },
{ new_file_name: 'add_mandatory_to_questions_table',
origin_file_name: 'migration_add_mandatory_to_questions_table' }]
migration_files.each do |migration_file|
next if already_exists?(migration_file[:new_file_name])
template "#{migration_file[:origin_file_name]}.rb.tt",
"db/migrate/#{timestamp_number}_#{migration_file[:new_file_name]}.rb"
timestamp_number += 1
end
end
|