Class: Migflow::Api::DiffController

Inherits:
Migflow::ApplicationController show all
Defined in:
app/controllers/migflow/api/diff_controller.rb

Instance Method Summary collapse

Methods inherited from Migflow::ApplicationController

#index

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/migflow/api/diff_controller.rb', line 6

def show
  return render_error("params 'from' and 'to' are required") unless from_version && to_version

  migrations = Parsers::MigrationParser.call(migrations_path: migrations_path)
  from_data  = find_migration(migrations, from_version)
  to_data    = find_migration(migrations, to_version)

  return render_error("One or both migrations not found", status: :not_found) unless from_data && to_data

  result = build_diff(migrations, from_data, to_data)
  render_json(diff: serialize_diff(result))
end