Class: Convergence::Command::Apply
Instance Method Summary
collapse
#initialize
Instance Method Details
#execute ⇒ Object
9
10
11
12
13
14
|
# File 'lib/convergence/command/apply.rb', line 9
def execute
current_dir_path = Pathname.new(@opts[:input]).realpath.dirname
dsl = Convergence::DSL.parse_dsl(File.open(@opts[:input]).read, current_dir_path)
current_tables = dumper.dump
execute_sql(dsl.tables, current_tables, dsl.raw_sqls)
end
|
#generate_sql(input_tables, current_tables, raw_sqls = []) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/convergence/command/apply.rb', line 16
def generate_sql(input_tables, current_tables, raw_sqls = [])
current_tables_with_full_option =
Convergence::DefaultParameter.append_database_default_parameter(current_tables, database_adapter)
input_tables_with_full_option =
Convergence::DefaultParameter.append_database_default_parameter(input_tables, database_adapter)
delta = Convergence::Diff
.new(ignore_auto_increment: @opts[:ignore_auto_increment])
.diff(current_tables_with_full_option, input_tables_with_full_option)
sql = sql_generator.generate(
input_tables_with_full_option,
delta,
current_tables_with_full_option,
safe_migration: @opts[:safe_migration]
)
append_raw_sqls(sql, raw_sqls)
end
|