aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-2/+2
| | | | Follow up of #31390.
* `current_version` should catch `NoDatabaseError` from `get_all_versions`Ryuta Kamizono2017-12-041-12/+5
| | | | | `get_all_versions` doesn't use passed `connection`. So it should be caught `NoDatabaseError` from `SchemaMigration.table_exists?`.
* Make `Migrator.current_version` work without a current databaseyuuji.yaginuma2017-12-031-1/+9
| | | | | | | This is necessary in order to make the processing dependent on `Migrator.current_version` work even without database. Context: https://github.com/rails/rails/pull/31135#issuecomment-348404326
* Update incorrect backtick usage in RDoc to teletypeT.J. Schuck2017-11-221-2/+2
| | | [ci skip]
* Fix migration version in doc of #up_onlybogdanvlviv2017-11-141-1/+1
|
* Add a #populate method to migrations (#31082)Rich2017-11-141-0/+18
| | | | | | | | | | | * Add a #populate method to migrations * Address rubocop issues * Rename to #up_only and use #execute in the examples intead of the model * Update CHANGELOG [Rich Daley & Rafael Mendonça França]
* Merge pull request #30773 from y-yagi/fix_30765Eileen M. Uchitelle2017-11-121-1/+2
|\ | | | | Make automatically synchronize test schema work inside engine
| * Make automatically synchronize test schema work inside engineyuuji.yaginuma2017-10-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rails engine, migration files are in under `db/migrate` of engine. Therefore, when rake task is executed in engine, `db/migrate` is automatically added to `DatabaseTasks.migrations_paths`. https://github.com/rails/rails/blob/a18cf23a9cbcbeed61e8049442640c7153e0a8fb/activerecord/lib/active_record/railtie.rb#L39..L43 However, if execute the rake task under dummy app, migration files will not be loaded because engine's migration path setting process is not called. Therefore, in order to load migration files correctly, it is necessary to execute rake task under engine. Fixes #30765
* | Fix `bin/rails db:migrate` with specified `VERSION`bogdanvlviv2017-11-061-1/+1
| | | | | | | | | | | | Ensure that `bin/rails db:migrate` with specified `VERSION` reverts all migrations only if `VERSION` is `0`. Raise error if target migration doesn't exist.
* | Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`Rafael Mendonça França2017-10-231-5/+0
|/
* Fix docs describing rollback [ci skip]dixpac2017-09-171-2/+2
| | | | | | | * `rails db:migrate STEP = 2` will not rollback the migrations, instead `rails db:rollback STEP = 2` will do the rollback. * Also, rewritten `rails db:migrate VERSION` => `rails db:rollback VERSION` for consistency.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Fix `test_copying_migrations_preserving_magic_comments`Ryuta Kamizono2017-07-021-4/+6
| | | | | Since #29540, `# frozen_string_literal: true` included original migration files.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-3/+3
|/
* Add additional raise UnknownMigrationVersionErrorbogdanvlviv2017-04-191-5/+7
| | | | | Raise error on the movement of migrations when the current migration does not exist.
* Fix `bin/rails db:forward` first migrationbogdanvlviv2017-04-191-1/+7
|
* Deprecate `Migrator.schema_migrations_table_name`Ryuta Kamizono2017-03-091-0/+5
| | | | | Since 67fba0cf `SchemaMigration` model was extracted. Use `SchemaMigration.table_name` instead.
* Extract `SchemaMigration.all_versions`Ryuta Kamizono2017-03-061-1/+1
| | | | | Use `SchemaMigration.all_versions` instead of `SchemaMigration.all.map(&:version)` to avoid to instantiate AR objects.
* Remove useless `Migrator.schema_migrations_table_name`Ryuta Kamizono2017-03-051-5/+1
| | | | Simply use `SchemaMigration.table_name` instead.
* Fix `rake db:migrate:status` with subdirectoriesRyuta Kamizono2017-03-041-7/+25
| | | | | | | | | | | | `db:migrate` supports subdirectories and have a test. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/test/cases/migrator_test.rb#L78-L85 But `db:migrate:status` doesn't work with subdirectories. It is due to `Dir.foreach(path)` is not the same with `Dir["#{path}/**/[0-9]*_*.rb"]`. I extracted `migration_files` and sharing it in the both to fix the issue. And added tests for `db:migrate:status`.
* Deprecate `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-8/+4
| | | | | | | `supports_migrations?` was added at 4160b518 to determine if schema statements (`create_table`, `drop_table`, etc) are implemented in the adapter. But all tested databases has been supported migrations since a4fc93c3 at least.
* show correct class name in migration inherited directly erroryuuji.yaginuma2017-01-241-1/+1
| | | | Follow up to 249f71a
* Deprecate `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-201-2/+2
| | | | | | `initialize_internal_metadata_table` These internal initialize methods are no longer used internally.
* Revert "Merge pull request #27718 from kamipo/remove_internal_public_methods"Matthew Draper2017-01-201-2/+2
| | | | | This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
* Remove `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-181-2/+2
| | | | | | | | | | | | `initialize_internal_metadata_table` internal public methods These internal methods accidentally appeared in the doc, and so almost useless. It is enough to create these internal tables directly, and indeed do so in several places. https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/schema.rb#L55 https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/railties/databases.rake#L6 https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/tasks/database_tasks.rb#L230
* class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-2/+2
| | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
* Preserve `up` and `down` return typeschneems2017-01-061-2/+4
| | | | | | In Rails 4.2 calling `ActiveRecord::Migrator.migrate` would return an array of results. Without realizing that this return type was expected I accidentally introduced a change in https://github.com/rails/rails/commit/4d60e93174a3d6d90b1a06fc7515cb5cd749a6f3 This PR preserves the previous behavior and adds a test on the return type. This will need a backport to 5.0 branch.
* Raises when `ActiveRecord::Migration` is inherited directly.Rafael Mendonça França2016-12-291-1/+4
|
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-6/+4
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-7/+7
|
* let Regexp#match? be globally availableXavier Noria2016-10-271-1/+0
| | | | | | Regexp#match? should be considered to be part of the Ruby core library. We are emulating it for < 2.4, but not having to require the extension is part of the illusion of the emulation.
* update doc about `change_column_default` [ci skip]yuuji.yaginuma2016-10-191-2/+4
| | | | Follow up to #20018.
* Add missing require for zlibLars Kanis2016-10-011-0/+1
| | | | | | | | | Zlib is used to generate the advisory lock since commit 2c2a8755460 . Using the Migrator fails since then, when it is called without the rails context: NameError: uninitialized constant ActiveRecord::Migrator::Zlib This patch fixes the above error.
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-5/+5
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-2/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-115/+115
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-6/+6
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* adds missing requiresXavier Noria2016-07-241-1/+2
|
* systematic revision of =~ usage in ARXavier Noria2016-07-231-1/+1
| | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* Remove tab chars before commands to be runÉtienne Barrié2016-07-201-4/+4
|
* Add missing space and newline for clarityKang-Kyu Lee2016-05-121-3/+3
|
* Fix small typo in Active Record Migrations documentation [ci skip]Erol Fornoles2016-05-031-1/+1
|
* Replace `Rails.version.to_f` with Active RecordJon Moss2016-04-301-1/+1
| | | | | Rails should not be explicity mentioned within Active Record, since railties and the Rails ecosystem is not required for use.
* Migrations: move version-finding responsibilityyui-knk2016-04-291-7/+1
| | | | | | | `ActiveRecord::Migration` needn't know about migration version compatibility lookup. Delegate it to the Compatibility module. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Cleanup message shown while running destructive action against protected ↵Prathamesh Sonpatki2016-04-101-2/+2
| | | | database.