aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-131-6/+6
| | | | Follow up of #32605.
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-5/+5
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-031-1/+1
| | | | | | 73e7aab behaved as expected on codeship, failing the build with exactly these RuboCop violations. Hopefully `rubocop -a` will have been enough to get a passing build!
* Fix occurrences Fixnum|Bignumbogdanvlviv2018-03-041-4/+2
| | | | Related to https://github.com/rails/rails/commit/d4eb0dc89ee6b476e2e10869dc282a96f956c6c7#r27830891
* Merge pull request #31189 from ↵Rafael França2018-02-271-0/+19
|\ | | | | | | | | tgxworld/raise_error_when_advisory_lock_is_not_releases Raise an error if advisory lock in migrator was not released.
| * Raise an error if advisory lock in migrator was not released.Guo Xiang Tan2017-11-211-0/+19
| |
* | Use assert_empty and assert_not_emptyDaniel Colson2018-01-251-4/+4
| |
* | Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-10/+10
| |
* | Merge pull request #31773 from dinahshi/postgresql_bulk_patchMatthew Draper2018-01-241-2/+3
|\ \ | | | | | | Postgresql bulk_change_table should flatten procs array
| * | Use concat to join procs arrays in bulk_change_tableDinah Shi2018-01-231-2/+3
| | |
* | | Refactor migration to move migrations paths to connectioneileencodes2018-01-181-28/+43
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* / Add bulk alter support for PostgreSQLDinah Shi2017-12-061-7/+27
|/
* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`Rafael Mendonça França2017-10-231-4/+0
|
* Remove deprecated method `supports_migrations?`Rafael Mendonça França2017-10-231-4/+0
|
* Remove deprecated methods `initialize_schema_migrations_table` and ↵Rafael Mendonça França2017-10-231-5/+0
| | | | `initialize_internal_metadata_table`
* Remove deprecated `#migration_keys`Ryuta Kamizono2017-08-221-4/+0
|
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-1/+3
|
* Fix `test_copying_migrations_preserving_magic_comments`Ryuta Kamizono2017-07-021-2/+2
| | | | | 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.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Fix `create_table` with query from relationRyuta Kamizono2017-06-131-6/+4
| | | | | If a relation has binds, `connection.to_sql(relation)` without binds will generate invalid SQL. It should use `relation.to_sql` in that case.
* Remove a duplicate test of migration_test in ARKoichi ITO2017-05-251-27/+0
|
* Deprecate `Migrator.schema_migrations_table_name`Ryuta Kamizono2017-03-091-0/+4
| | | | | Since 67fba0cf `SchemaMigration` model was extracted. Use `SchemaMigration.table_name` instead.
* Remove useless `Migrator.schema_migrations_table_name`Ryuta Kamizono2017-03-051-5/+5
| | | | Simply use `SchemaMigration.table_name` instead.
* Deprecate `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-0/+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.
* Deprecate `ColumnDumper#migration_keys`Ryuta Kamizono2017-02-071-0/+4
| | | | | | `ColumnDumper#migration_keys` was extracted to customize keys for standardized column arguments widths. But the feature was removed in df84e98. The internal method is no longer used for that.
* Deprecate `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-201-4/+8
| | | | | | `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-3/+3
| | | | | This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
* Remove `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-181-3/+3
| | | | | | | | | | | | `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
* Fix random failure related to migration environmentPrathamesh Sonpatki2017-01-071-0/+2
| | | | | | | | | | | - Reference: https://travis-ci.org/rails/rails/jobs/189764676 - Reproduction command: MTB_VERBOSE=2 bundle exec minitest_bisect --seed 33328 -Itest "test/cases/migration_test.rb" "test/cases/tasks/database_tasks_test.rb" - You need to also add minitest_bisect gem to the Gemfile to reproduce this failure.
* Privatize unneededly protected methods in Active RecordAkira Matsuda2017-01-051-1/+1
|
* Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-241-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-4/+4
|
* Added nil case handling to allow rollback migration in case oftravis.h.oneill@gmail.com2016-08-171-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid column type /activerecord/lib/active_record/connection_adapters /abstract/schema_definitions.rb:306 type = type.to_sym Changed to the following to handle nil case: type = type.to_sym if type Added regression test for this case: /activerecord/test/cases/migration_test.rb:554 if current_adapter?(:SQLite3Adapter) def test_allows_sqlite3_rollback_on_invalid_column_type Person.connection.create_table :something, force: true do |t| t.column :number, :integer t.column :name, :string t.column :foo, :bar end assert Person.connection.column_exists?(:something, :foo) assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar } assert !Person.connection.column_exists?(:something, :foo) assert Person.connection.column_exists?(:something, :name) assert Person.connection.column_exists?(:something, :number) ensure Person.connection.drop_table :something, if_exists: true end end
* Add three new rubocop rulesRafael Mendonça França2016-08-161-6/+6
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-18/+18
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-10/+10
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-35/+35
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-45/+45
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Revert "Rename `active_record_internal_metadatas` to `ar_internal_metadata`"Yasuo Honda2016-07-011-15/+0
| | | | This reverts commit 407e0ab5e5cddf6a8b6b278b12f50772d13b4d86.
* Merge pull request #24732 from y-yagi/update_record_specified_in_the_keyRafael França2016-05-211-0/+17
|\ | | | | update record specified in key
| * update record specified in keyyuuji.yaginuma2016-04-271-0/+17
| | | | | | | | | | | | `#first_or_initialize` does not use attributes to data acquisition. Therefore, there is a possibility of updating the different record than the one specified in the key, I think this is not expected behavior.
* | Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+2
| | | | | | | | | | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* | Replace `Rails.version.to_f` with Active RecordJon Moss2016-04-301-0/+4
|/ | | | | Rails should not be explicity mentioned within Active Record, since railties and the Rails ecosystem is not required for use.
* Change for `ActiveRecord::Migration.[]` to raise `ArgumentError` instead of ↵yui-knk2016-03-241-0/+3
| | | | | | | | | `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.
* Ensure `drop_table` even if tests failure or interruptedRyuta Kamizono2016-02-241-7/+5
| | | | | | I was encountered remaining `:binary_testings` table by tests failure. When remaining `:binary_testings` table, never reach `drop_table` due to `create_table` in the test always fails.
* `drop_table :test_text_limits` as wellRyuta Kamizono2016-02-241-9/+13
| | | | Follow up to 3b01785.
* Merge pull request #23789 from ↵Rafael França2016-02-231-1/+1
|\ | | | | | | | | wisetara/wisetara/deprecate-args-ActiveSupport__TestCase#assert_nothing_raised-for-pr Wisetara/deprecate args active support test case#assert nothing raised for pr