aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/ar_schema_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Move SchemaMigration to migration_contexteileencodes2019-06-141-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* Fix `presicion` -> `precision`yuuji.yaginuma2019-04-131-4/+4
| | | | This fix is necessary to test precision's default correctly.
* Ensure `reset_table_name` when table name prefix/suffix is changedRyuta Kamizono2019-04-041-4/+5
| | | | | Also, `reset_column_information` is unnecessary since `reset_table_name` does that too.
* Make `t.timestamps` with precision by defaultRyuta Kamizono2019-01-261-0/+51
|
* Fix `t.timestamps` missing `null: false` in `change_table bulk: true`Ryuta Kamizono2019-01-261-0/+15
|
* Allow `column_exists?` giving options without typeRyuta Kamizono2019-01-261-6/+6
|
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-6/+6
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Refactor migration to move migrations paths to connectioneileencodes2018-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 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 `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-110/+107
| | | | | | | `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.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-2/+2
|
* Merge pull request #26019 from agrobbin/schema-load-unique-column-indicesRafael França2016-08-161-0/+16
|\ | | | | Support multiple indexes on the same column when loading the schema
| * support multiple indexes on the same column when loading the schemaAlex Robbin2016-08-021-0/+16
| |
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-4/+4
| |
* | applies new string literal convention in activerecord/testXavier 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.
* Make to primary key instead of an unique index for internal tablesRyuta Kamizono2016-01-311-1/+1
|
* Get update_attributes working with SchemaMigrationschneems2016-01-081-2/+2
| | | | You cannot use `update_attributes` on models that do not have a primary key. Since SchemaMigration versions are guaranteed to be unique (they have a unique index on them) we can safely use them as a primary key.
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-51/+20
|
* synchronize code and docs for `timestamps` and `add_timestamps`.Yves Senn2014-11-201-0/+9
| | | | | | | | This makes the following changes: * warn if `:null` is not passed to `add_timestamps` * `timestamps` method docs link to `add_timestamps` docs * explain where additional options go * adjust examples to include `null: false` (to prevent deprecation warnings)
* Merge pull request #16827 from kuldeepaggarwal/f-disable-migration-loggingYves Senn2014-09-081-1/+4
|\ | | | | | | disable migrations logging while running test cases for AR schema tests
| * disable migrations logging while running test cases for AR schema testsKuldeep Aggarwal2014-09-061-0/+2
|/
* Change the default `null` value for timestampsSean Griffin2014-08-121-0/+57
| | | | | | | As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
* `ActiveRecord::SchemaMigration` has no primary key.Yves Senn2014-06-061-0/+14
| | | | | | | | | | Before this patch, using `ActiveRecord::Base.primary_key_prefix_type` with `:table_name_with_underscore` would change the `SchemaMigration` model to have a primary key. This resulted in broken queries for PG because it tried to return the inserted PK (which does not exist). Closes #15051. Closes #15419.
* test refactor, don't hardcode default for `table_name_prefix`.Yves Senn2014-06-061-1/+2
|
* `bin/rake db:migrate:status` works with legacy migration numbers.Yves Senn2014-06-061-0/+7
| | | | | | | The migration numbers were normalized different ways. This left the task output in an inconsistent state. Closes #15538.
* Use teardown helper method.Guo Xiang Tan2014-03-141-1/+1
| | | | | | | | Follow-Up to https://github.com/rails/rails/pull/14348 Ensure that SQLCounter.clear_log is called after each test. This is a step to prevent side effects when running tests. This will allow us to run them in random order.
* Call assume_migrated_upto_version on connectionKyle Stevens2013-05-111-0/+20
| | | | | | | | | | | 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.
* Reset SchemaMigration after updatingAkira Matsuda2013-01-221-0/+1
|
* Needs to reset SchemaMigration first, or the tests fail in sqlite3Akira Matsuda2013-01-071-1/+1
|
* Move to the schema-migrations-metadata branch.Jeremy Kemper2012-12-091-51/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Add migration history to schema.rb dumpJosh Susser2012-12-021-0/+51
|
* Call methods on the correct instance in AR::Schema.defineJohn Firebaugh2012-05-161-0/+7
| | | | | 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.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* fixing typoNeeraj Singh2010-07-181-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* ActiveRecord should raise an error on invalid migration types.José Valim2010-02-281-0/+10
|
* Autoload ActiveRecord filesJoshua Peek2008-11-241-1/+0
|
* Add support for interleaving migrations by storing which migrations have run ↵Rick Olson2008-04-091-2/+2
| | | | | | 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
* Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/railsJeremy Kemper2008-01-211-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Move tests to casesJeremy Kemper2008-01-181-0/+33
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de