aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema.rb
Commit message (Collapse)AuthorAgeFilesLines
* Move SchemaMigration to migration_contexteileencodes2019-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This PR moves the `schema_migration` to `migration_context` so that we can access the `schema_migration` per connection. This does not change behavior of the SchemaMigration if you are using one database. This also does not change behavior of any public APIs. `Migrator` is private as is `MigrationContext` so we can change these as needed. We now need to pass a `schema_migration` to `Migrator` so that we can run migrations on the right connection outside the context of a rake task. The bugs this fixes were discovered while debugging the issues around the SchemaCache on initialization with multiple database. It was clear that `get_all_versions` wouldn't work without these changes outside the context of a rake task (because in the rake task we establish a connection and change AR::Base.connection to the db we're running on). Because the `SchemaCache` relies on the `SchemaMigration` information we need to make sure we store it per-connection rather than on ActiveRecord::Base. [Eileen M. Uchitelle & Aaron Patterson]
* Deprecate passing `migrations_paths` to ↵Ryuta Kamizono2018-12-281-10/+1
| | | | | | | `connection.assume_migrated_upto_version` Since #31727, `migrations_paths` in `assume_migrated_upto_version` is no longer used.
* Refactor migration to move migrations paths to connectioneileencodes2018-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rails has some support for multiple databases but it can be hard to handle migrations with those. The easiest way to implement multiple databases is to contain migrations into their own folder ("db/migrate" for the primary db and "db/seconddb_migrate" for the second db). Without this you would need to write code that allowed you to switch connections in migrations. I can tell you from experience that is not a fun way to implement multiple databases. This refactoring is a pre-requisite for implementing other features related to parallel testing and improved handling for multiple databases. The refactoring here moves the class methods from the `Migrator` class into it's own new class `MigrationContext`. The goal was to move the `migrations_paths` method off of the `Migrator` class and onto the connection. This allows users to do the following in their `database.yml`: ``` development: adapter: mysql2 username: root password: development_seconddb: adapter: mysql2 username: root password: migrations_paths: "db/second_db_migrate" ``` Migrations for the `seconddb` can now be store in the `db/second_db_migrate` directory. Migrations for the primary database are stored in `db/migrate`". The refactoring here drastically reduces the internal API for migrations since we don't need to pass `migrations_paths` around to every single method. Additionally this change does not require any Rails applications to make changes unless they want to use the new public API. All of the class methods from the `Migrator` class were `nodoc`'d except for the `migrations_paths` and `migrations_path` getter/setters respectively.
* Prefer formatted number as schema version [ci skip]Ryuta Kamizono2017-08-211-1/+1
|
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* 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.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Deprecate `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-201-1/+1
| | | | | | `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-1/+1
| | | | | This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
* Remove `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-181-1/+1
| | | | | | | | | | | | `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
* No need to nodoc private methodsAkira Matsuda2016-12-241-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Use hash like syntax for InternalMetadataschneems2016-01-081-1/+1
| | | | Discussion: https://github.com/rails/rails/pull/22967#discussion_r49137035
* Prevent destructive action on production databaseschneems2016-01-071-0/+3
| | | | | | | 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`.
* Schema uses current migration APIMatthew Draper2015-12-151-1/+1
|
* applies new doc guidelines to Active Record.Yves Senn2015-10-141-3/+4
| | | | | | | | | | | | | | | | | | | The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
* adjust method visibility according to it's usage.Yves Senn2015-09-091-18/+18
| | | | | `Schema#migrations_paths` is not supposed to be public API. In fact it's only used inside `Schema` itself, so let's make it private.
* Invert the conditionalRafael Mendonça França2015-09-091-1/+1
|
* remove blank lines in the start of the ActiveRecord filesPonomarev Nikolay2014-07-291-1/+0
|
* Call assume_migrated_upto_version on connectionKyle Stevens2013-05-111-1/+1
| | | | | | | | | | | Call assume_migrated_upto_version on connection to prevent it from first being picked up in method_missing. In the base class, Migration, method_missing expects the argument to be a table name, and calls proper_table_name on the arguments before sending to connection. If table_name_prefix or table_name_suffix is used, the schema version changes to prefix_version_suffix, breaking `rake test:prepare`. Fixes #10411.
* Move to the schema-migrations-metadata branch.Jeremy Kemper2012-12-091-29/+11
| | | | | | | | | | | | | | | | | | | | | | | | Pending work on graceful app upgrades. Revert "Merge pull request #8439 from joshsusser/fixes" This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing changes made to b0e7b6f67c984d4b1502e801781ed75fad681633. Revert "Merge pull request #8431 from joshsusser/schemadump" This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e. Revert "Merge branch 'joshsusser-master' into merge" This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/schema_dumper_test.rb
* Merge branch 'joshsusser-master' into mergeAaron Patterson2012-12-051-11/+29
|\ | | | | | | | | | | | | | | | | | | | | * joshsusser-master: style cleanup Add migration history to schema.rb dump Add metadata to schema_migrations Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/schema.rb
| * Add migration history to schema.rb dumpJosh Susser2012-12-021-11/+29
| |
* | update AR::Schema docs [ci skip]Carlos Duclos2012-12-011-1/+6
|/
* Dump schema using new style hashKonstantin Shabanov2012-09-081-4/+4
|
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* Call methods on the correct instance in AR::Schema.defineJohn Firebaugh2012-05-161-7/+10
| | | | | Now that migrations support instance methods, we should use the same instance rather than relying on delegation to a global instance. This allows subclassing AR::Schema.
* Allow to run migrations from more than one directoryPiotr Sarnacki2010-12-091-3/+3
|
* rolling out migrated_at until I can fix the buildAaron Patterson2010-12-011-15/+4
|
* tests mostly passJosh Susser2010-12-011-1/+1
| | | | | adjust to work with instance-based migations migrated_at can't be null why must people have last names? it's killing me!
* clear schema_migrations in Schema.defineJosh Susser2010-12-011-1/+3
|
* name in schema_migrations, migrations in schema dumpJosh Susser2010-12-011-4/+13
|
* schema migrations work as instancesAaron Patterson2010-11-171-2/+3
|
* converted migrations to support instance methodsAaron Patterson2010-11-171-4/+2
|
* fixing whitespace errorsAaron Patterson2010-08-051-1/+1
|
* Adds title where needed.Rizwan Reza2010-06-161-0/+2
|
* adds missing requires for Object#blank? and Object#present?Xavier Noria2010-03-281-0/+2
|
* Allow AR::Schema's migrations_path to be overwritten by subclasses. Defaults ↵Jeffrey Hardy2010-01-081-1/+5
| | | | | | | | to 'db/migrate' [#3671 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Merge docrails.Pratik Naik2008-05-251-2/+2
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Add support for interleaving migrations by storing which migrations have run ↵Rick Olson2008-04-091-12/+5
| | | | | | in the new schema_migrations table. Closes #11493 [jordi] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9244 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Update Schema documentation to use updated sexy migration notation. Closes ↵Marcel Molina2007-11-061-5/+5
| | | | | | #10086 [sjgman9] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8089 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Makes ActiveRecord::Schema respect AR::Base.table_name_prefix (closes #3848) ↵David Heinemeier Hansson2006-02-251-2/+2
| | | | | | [rubyonrails@atyp.de] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3648 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Improved the Oracle OCI Adapter with better performance for column ↵David Heinemeier Hansson2006-02-211-1/+1
| | | | | | reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) (closes #3879) [Aggregated by schoenm@earthlink.net] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3623 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Update/clean up ActiveRecord documentation (rdoc)Jamis Buck2005-10-161-1/+37
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Refactored the AbstractAdapter to be a lot less scary. Cleaned up the docs ↵David Heinemeier Hansson2005-09-251-1/+2
| | | | | | and style for the OSS adapters git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2339 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Just include activerecord/schema with AR so it doesnt need to be dumpedDavid Heinemeier Hansson2005-09-241-2/+0
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2322 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, ↵Jamis Buck2005-09-231-0/+23
making it easier to consolidate large migration lists and port database schemas between databases. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2312 5ecf4fe2-1ee6-0310-87b1-e25e094e27de