diff options
author | yui-knk <spiketeika@gmail.com> | 2015-10-02 01:21:37 +0900 |
---|---|---|
committer | yui-knk <spiketeika@gmail.com> | 2015-11-02 23:06:57 +0900 |
commit | a7beeb7faac405de0f78c39dbfb7240a584d0d10 (patch) | |
tree | c7b58555604d401eeabe1ea3cbf05e44c6dc31a0 /railties/test/application | |
parent | ab3510367bd4622f836374e5a37e54381ea72fc6 (diff) | |
download | rails-a7beeb7faac405de0f78c39dbfb7240a584d0d10.tar.gz rails-a7beeb7faac405de0f78c39dbfb7240a584d0d10.tar.bz2 rails-a7beeb7faac405de0f78c39dbfb7240a584d0d10.zip |
Make `db:migrate:status` to render `1_some.rb` format migrate files.
`1_valid_people_have_last_names.rb` and
`20150823202140_create_users.rb` are valid migration file name.
But `1_valid_people_have_last_names.rb` is rendered as
`********** NO FILE **********` when `rake db:migrate:status`.
Fix to this bug, this commit includes
* define some API private methdos and a Constant
`match_to_migration_filename?`, `parse_migration_filename`, and
`MigrationFilenameRegexp`
* use these methods in `db:migrate:status` task
Example:
These files are in `db/migrate`
* 1_valid_people_have_last_names.rb
* 20150819202140_irreversible_migration.rb
* 20150823202140_add_admin_flag_to_users.rb
* 20150823202141_migration_tests.rb
* 2_we_need_reminders.rb
* 3_innocent_jointable.rb
we can migrate all of them.
Before
```shell
$ bundle exec rake db:migrate:status
...
Status Migration ID Migration Name
--------------------------------------------------
up 001 ********** NO FILE **********
up 002 ********** NO FILE **********
up 003 ********** NO FILE **********
up 20150819202140 Irreversible migration
up 20150823202140 Add admin flag to users
up 20150823202141 Migration tests
```
After
```shell
$ bundle exec rake db:migrate:status
...
Status Migration ID Migration Name
--------------------------------------------------
up 001 Valid people have last names
up 002 We need reminders
up 003 Innocent jointable
up 20150819202140 Irreversible migration
up 20150823202140 Add admin flag to users
up 20150823202141 Migration tests
```
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/rake/migrations_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 2d8bd7c571..6b74707959 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -154,6 +154,28 @@ module ApplicationTests end end + test 'running migrations with not timestamp head migration files' do + Dir.chdir(app_path) do + + app_file "db/migrate/1_one_migration.rb", <<-MIGRATION + class OneMigration < ActiveRecord::Migration + end + MIGRATION + + app_file "db/migrate/02_two_migration.rb", <<-MIGRATION + class TwoMigration < ActiveRecord::Migration + end + MIGRATION + + `bin/rake db:migrate` + + output = `bin/rake db:migrate:status` + + assert_match(/up\s+001\s+One migration/, output) + assert_match(/up\s+002\s+Two migration/, output) + end + end + test 'schema generation when dump_schema_after_migration is set' do add_to_config('config.active_record.dump_schema_after_migration = false') |