aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-04-031-1/+1
|\
| * format as code [ci-skip]Gaurish Sharma2016-03-141-1/+1
| |
* | Change for `ActiveRecord::Migration.[]` to raise `ArgumentError` instead of ↵yui-knk2016-03-241-1/+1
|/ | | | | | | | | `RuntimeError` The error is raised because user passed invalid version number to a public api of `ActiveRecord`, so `ArgumentError` is more suitable. And add a test case checking if an error is raised when unknown migration version is passed, because these test cases are not implemented.
* refer to rails command instead of rake in environment erroryuuji.yaginuma2016-01-191-2/+2
| | | | It has been to use an overall rails command in ea4f0e2baba8653b03fba154357842933cf7b778, in order to unify.
* Revert "Revert "Set environment even when no migration runs""schneems2016-01-141-18/+30
| | | | This reverts commit 11e85b91731ca6125ee1db33553f984549a3bc2b.
* Revert "Set environment even when no migration runs"Sean Griffin2016-01-141-30/+18
|
* Merge pull request #23017 from ↵Richard Schneeman2016-01-141-18/+30
|\ | | | | | | | | schneems/schneems/migration-sets-environment-value Set environment even when no migration runs
| * Set environment even when no migration runsschneems2016-01-111-1/+10
| | | | | | | | | | This PR addresses the issue described in https://github.com/rails/rails/pull/22967#issuecomment-170251635. If the database is non empty and has no new migrations than `db:migrate` will not set the environment. This PR works by always setting the environment value on successful `up` migration regardless of whether or not a migration was actually executed.
| * Clean up duplicate migration logicschneems2016-01-111-17/+20
| |
* | Allow manually setting environment valueschneems2016-01-111-6/+11
|/ | | | | | | | If for some reason some one is not able to set the environment from a migration this gives us an escape valve to manually set the environment for the database see https://github.com/rails/rails/pull/22967#issuecomment-170251635. We will also fix the migration case, but this will ensure there is always a way to set the environment. cc/ @sgrif
* Merge pull request #22967 from schneems/schneems/generic-metadataSean Griffin2016-01-081-1/+49
|\ | | | | Prevent destructive action on production database
| * Fixing tests and re-locating error checking.schneems2016-01-081-7/+8
| |
| * Fix kwarg to not have circular dependencyschneems2016-01-081-1/+1
| |
| * Use hash like syntax for InternalMetadataschneems2016-01-081-3/+3
| | | | | | | | Discussion: https://github.com/rails/rails/pull/22967#discussion_r49137035
| * Add EnvironmentMismatchErrorschneems2016-01-081-2/+14
| | | | | | Raise an error when a destructive action is made on a database where the current environment is different from the environment stored in the database.
| * Prevent destructive action on production databaseschneems2016-01-071-1/+36
| | | | | | | | | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* | Lets not put fullstop at the end of a migration pending commandPrathamesh Sonpatki2015-12-311-2/+2
| | | | | | | | - So that we can just copy paste the command and execute it
* | Refer to rails command instead of rake in a bunch of placesDavid Heinemeier Hansson2015-12-181-6/+6
|/ | | | Still more to do. Please assist!
* Use a real migration version number in docsMatthew Draper2015-12-151-15/+15
| | | | | Even though this means more things to change when we bump after a release, it's more important that our examples are directly copyable.
* Find the delegate, even in a deeper inheritance treeMatthew Draper2015-12-151-1/+5
|
* Use a deliberately-invalid migration version in all doc examplesMatthew Draper2015-12-151-15/+15
| | | | | | | | | | If we use a real version, at best that'll be an onerous update required for each release; at worst, it will encourage users to write new migrations against an older version than they're using. The other option would be to leave these bare, without any version specifier. But as that's just a variant spelling of "4.2", it would seem to raise the same concerns as above.
* Add migration versioning via Migration subclassesMatthew Draper2015-12-151-0/+26
|