-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
The migrations path was finally set as a separate method in the official migration code since AR 5.0.2.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,8 @@ module Generators | |
class MigrationGenerator < ::ActiveRecord::Generators::MigrationGenerator | ||
source_root ::ActiveRecord::Generators::MigrationGenerator.source_root | ||
|
||
def create_migration_file | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rosenfeld
Author
Owner
|
||
set_local_assigns! | ||
validate_file_name! | ||
dir = ::ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first | ||
migration_template @migration_template, "#{dir}/#{file_name}.rb" | ||
def db_migrate_path | ||
::ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ActiveRecordMigrations | ||
VERSION = "5.0.1.1" | ||
VERSION = "5.0.2.1" | ||
end |
4 comments
on commit 32c3e8c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how you solved this. It's annoying that an API like this changed on a patch release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that it's not really a public API. That's one of the main reasons I wasn't comfortable with patching the generator so that we could use the migrations path from the configurations. This method could change on any patch release since it's an implementation detail rather than a public API. I tried once to submit a patch to extract the path to a separate method years ago when I created this gem, but it was ignored if I recall correctly. I was happy to see that someone committed that change to Rails recently in rails/rails#27674
5.0.2 was the first release with this change included. I still have to override a private method, however it's very unlikely that someone would rename or remove the new db_migrate_path
method, so I feel confident enough to relax on the versioning requirements for ActiveRecord. I was mostly worried about overriding create_migration_file
, as it is a critical method with lots of behavior, and I always had to check on whether the implementation for it has changed before each new release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I hear what you are saying, based on my experience with AR, it's probably going to break again in the future :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that this change didn't actually break anything since this was an internal implementation detail. Nothing has changed in public APIs. I understand you don't appreciate incompatibilities introduced often by ActiveRecord, but they don't actually affect me because I don't actually use ActiveRecord as an ORM. I just use its migrations framework and use Sequel as the ORM. That means any incompatibilities in AR won't affect our application, except if they affect the migrations framework and so far I didn't see any changes in this framework that would cause any incompatibilities...
If you retain this function, like so https://github.com/ioquatix/activerecord-migrations/blob/master/lib/active_record/migrations/generator.rb you can work all current versions of AR ~> 5.0
However, it's possible it breaks in the future. As it is with any code..