New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migrations_paths option to migration generator #33760

Merged
merged 1 commit into from Aug 30, 2018

Conversation

Projects
None yet
2 participants
@eileencodes
Member

eileencodes commented Aug 30, 2018

Summary

Adds an option to the migration generator to allow setting the
migrations paths for that migration. This is useful for applications
that use multiple databases and put migrations per database in their own
directories.

bin/rails g migration CreateHouses address:string --migrations-paths=db/kingston_migrate
      invoke  active_record
      create    db/kingston_migrate/20180830151055_create_houses.rb
Add migrations_paths option to migration generator
Adds an option to the migration generator to allow setting the
migrations paths for that migration. This is useful for applications
that use multiple databases and put migrations per database in their own
directories.

```
bin/rails g migration CreateHouses address:string --migrations-paths=db/kingston_migrate
      invoke  active_record
      create    db/kingston_migrate/20180830151055_create_houses.rb
```

@eileencodes eileencodes added this to the 6.0.0 milestone Aug 30, 2018

@eileencodes eileencodes merged commit 9f1d8f9 into rails:master Aug 30, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@eileencodes eileencodes deleted the eileencodes:add-migrations_paths_option-to-migration-generator branch Aug 30, 2018

@@ -24,7 +24,9 @@ def primary_key_type
end
def db_migrate_path
if defined?(Rails.application) && Rails.application
if migrations_paths = options[:migrations_paths]

This comment has been minimized.

@kamipo

kamipo Aug 30, 2018

Member

Is there any reason that named plural paths here even this db_migrate_path method returns a single path unlike other migrations_paths?

self.migrations_paths = ["db/migrate"]

def migrations_paths
@migrations_paths ||= Rails.application.paths["db/migrate"].to_a
end

@kamipo

kamipo Aug 30, 2018

Member

Is there any reason that named plural paths here even this db_migrate_path method returns a single path unlike other migrations_paths?

self.migrations_paths = ["db/migrate"]

def migrations_paths
@migrations_paths ||= Rails.application.paths["db/migrate"].to_a
end

This comment has been minimized.

@eileencodes

eileencodes Aug 30, 2018

Member

Was just using the same name that's used everywhere else.

@eileencodes

eileencodes Aug 30, 2018

Member

Was just using the same name that's used everywhere else.

bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Oct 15, 2018

Unify changelog entries related to `database` option of Rails generat…
…ors [ci skip]

`migrations_paths` option was added to migration generator, with
changelog entry, in rails#33760.
Also `migrations_paths` option was added to model generator, with
changelog entry, in rails#33994.
Then `migrations_paths` was renamed to `database` and aliased as `db`
in rails#34021, and was added new changelog entry.
I think we should edit existed changelog entries instead adding new
about changing the name of the option from `migrations_paths` to `database`
since Rails 6.0 hasn't been released yet, and since It might confuse
readers of the changelog file in case if they've read changelog enty about
adding `migrations_paths` option but haven't read the entry about
change the name of that option to `database`.
@eileencodes, @gmcgibbon, @rafaelfranca Does it make sense?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment