Skip to content

Commit

Permalink
Change the sorting to DESC
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSokov committed Jul 15, 2024
1 parent 90ed98a commit fac34bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/actual_db_schema/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def all_phantom
end
end

migrations
sort_migrations_desc(migrations)
end

def all
Expand All @@ -54,7 +54,7 @@ def all
end
end

migrations
sort_migrations_desc(migrations)
end

def find(version, database)
Expand Down Expand Up @@ -105,6 +105,10 @@ def build_migration_struct(status, migration)
)
end

def sort_migrations_desc(migrations)
migrations.sort_by { |migration| migration[:version].to_i }.reverse if migrations.any?
end

def find_migration_in_context(context, version)
migration = context.migrations.detect { |m| m.version.to_s == version }
return unless migration
Expand Down
2 changes: 1 addition & 1 deletion test/dummy_app/db/secondary_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2013_09_06_111513) do
ActiveRecord::Schema.define(version: 2013_09_06_111515) do

end

0 comments on commit fac34bd

Please sign in to comment.