diff --git a/app/controllers/actual_db_schema/migrations_controller.rb b/app/controllers/actual_db_schema/migrations_controller.rb
index 556a379..ea9b88d 100644
--- a/app/controllers/actual_db_schema/migrations_controller.rb
+++ b/app/controllers/actual_db_schema/migrations_controller.rb
@@ -5,7 +5,9 @@ module ActualDbSchema
class MigrationsController < ActionController::Base
def index; end
- def show; end
+ def show
+ render :not_found, status: 404 unless migration
+ end
def rollback
rollback_migration(params[:id], params[:database])
@@ -18,15 +20,8 @@ def rollback
ActualDbSchema::Migration.instance.all
end
- helper_method def load_migration(version, database)
- ActualDbSchema.for_each_db_connection do
- next unless ActualDbSchema.db_config[:database] == database
-
- context = ActualDbSchema.prepare_context
- migration = find_migration_in_context(context, version)
- return migration if migration
- end
- nil
+ helper_method def migration
+ ActualDbSchema::Migration.find(params[:id], params[:database])
end
def rollback_migration(version, database)
@@ -51,13 +46,5 @@ def build_migration_struct(status, migration)
filename: migration.filename
)
end
-
- def find_migration_in_context(context, version)
- migration = context.migrations.detect { |m| m.version.to_s == version }
- return unless migration
-
- status = context.migrations_status.detect { |_s, v| v.to_s == version }&.first || "unknown"
- build_migration_struct(status, migration)
- end
end
end
diff --git a/app/views/actual_db_schema/migrations/show.html.erb b/app/views/actual_db_schema/migrations/show.html.erb
index 150a833..1a88150 100644
--- a/app/views/actual_db_schema/migrations/show.html.erb
+++ b/app/views/actual_db_schema/migrations/show.html.erb
@@ -6,45 +6,40 @@
- <% if migration = load_migration(params[:id], params[:database]) %>
-
Migration <%= migration[:name] %> Details
-
-
-
- Status |
- <%= migration[:status] %> |
-
-
- Migration ID |
- <%= migration[:version] %> |
-
-
- Branch |
- <%= migration[:branch] %> |
-
-
- Database |
- <%= migration[:database] %> |
-
-
- Path |
- <%= migration[:filename] %> |
-
-
-
+
Migration <%= migration[:name] %> Details
+
+
+
+ Status |
+ <%= migration[:status] %> |
+
+
+ Migration ID |
+ <%= migration[:version] %> |
+
+
+ Branch |
+ <%= migration[:branch] %> |
+
+
+ Database |
+ <%= migration[:database] %> |
+
+
+ Path |
+ <%= migration[:filename] %> |
+
+
+
-
Migration Code
-
-
<%= File.read(migration[:filename]) %>
-
-
- <%= link_to 'Back', migrations_path, class: 'button' %>
- <%= button_to 'Rollback', rollback_migration_path(id: params[:id], database: params[:database]), method: :post, class: 'button' %>
-
- <% else %>
-
Migration not found
+
Migration Code
+
+
<%= File.read(migration[:filename]) %>
+
+
<%= link_to 'Back', migrations_path, class: 'button' %>
- <% end %>
+ <%= button_to 'Rollback', rollback_migration_path(id: params[:id], database: params[:database]), method: :post, class: 'button' %>
+