aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration
Commit message (Collapse)AuthorAgeFilesLines
* `rename_table` renames primary key index nameYaw Boakye2017-05-291-0/+23
| | | | | | | | | | Formerly, `rename_table` only renamed primary key index name if the column's data type was sequential (serial, etc in PostgreSQL). The problem with that is tables whose primary keys had other data types (e.g. UUID) maintained the old primary key name. So for example, if the `cats` table has a UUID primary key, and the table is renamed to `felines`, the primary key index will still be called `cats_pkey` instead of `felines_pkey`. This PR corrects it.
* Remove a redundant test case of command_recorder_testKoichi ITO2017-05-291-5/+0
|
* Both reference id and type should be `NOT NULL` if `null: false` is specifiedRyuta Kamizono2017-05-191-0/+8
| | | | | | This is a regression due to #28282. Fixes #29136.
* Use a query that's compatible with PostgreSQL 9.2Matthew Draper2017-04-121-1/+1
| | | | | | Also, explicitly apply the order: generate_subscripts is unlikely to start returning values out of order, but we should still be clear about what we want.
* Don't share `options` with a reference type columnRyuta Kamizono2017-03-041-0/+7
| | | | | | | | | Sharing `options` causes some unexpected behavior. If `limit: 2` is specified, this means that 2 bytes integer for a reference id column and 2 chars string for a reference type column. Another example, if `unsigned: true` is specified, this means that unsigned integer for a reference id column, but a invalid option for a reference type column. So `options` should not be shared with a reference type column.
* `create_join_table` should respect `references` column typeRyuta Kamizono2017-02-281-1/+12
| | | | | | | | Follow up of #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But `create_join_table` column type is still `integer`. It should respect `references` column type.
* Deprecate `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-12/+0
| | | | | | | `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.
* Fix `change_column` to drop default with `null: false`Ryuta Kamizono2017-02-261-0/+10
| | | | | | | | | | | | | | | | Currently `change_column` cannot drop default if `null: false` is specified at the same time. This change fixes the issue. ```ruby # cannot drop default change_column "tests", "contributor", :boolean, default: nil, null: false # we need the following workaround currently change_column "tests", "contributor", :boolean, null: false change_column "tests", "contributor", :boolean, default: nil ``` Closes #26582
* Merge pull request #25285 from ↵Rafael França2017-02-231-0/+16
|\ | | | | | | | | kamipo/fix_remove_reference_to_multiple_foreign_keys_in_the_same_table Fix `remove_reference` to multiple foreign keys in the same table
| * Fix `remove_reference` to multiple foreign keys in the same tableRyuta Kamizono2017-02-111-0/+16
| |
* | Correctly dump native timestamp types for MySQLRyuta Kamizono2017-02-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native timestamp type in MySQL is different from datetime type. Internal representation of the timestamp type is UNIX time, This means that timestamp columns are affected by time zone. ``` > SET time_zone = '+00:00'; Query OK, 0 rows affected (0.00 sec) > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW()); Query OK, 1 row affected (0.02 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) > SET time_zone = '-08:00'; Query OK, 0 rows affected (0.00 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) ```
* | Remove unused DdlHelper in ForeignKeyTestRyuta Kamizono2017-02-141-2/+0
| |
* | Use ActiveRecord `bigint` type, not SQL literal bigintYasuo Honda2017-02-141-11/+14
| | | | | | | | | | | | | | | | Oracle database itself does not have `bigint` SQL type, then it gets `ORA-00902: invalid datatype`. It can be addressed by using ActiveRecord `bigint` type because Oracle enhanced adapter recognizes ActiveRecord `bigint` type and transfer it to its equivalent SQL type `NUMBER(19)`.
* | Deprecate passing `default` to `index_name_exists?`Ryuta Kamizono2017-02-131-2/+4
| |
* | The `default` arg of `index_name_exists?` makes to optionalRyuta Kamizono2017-02-131-8/+6
|/ | | | | | The `default` arg of `index_name_exists?` is only used the adapter does not implemented `indexes`. But currently all adapters implemented `indexes` (See #26688). Therefore the `default` arg is never used.
* `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-073-14/+13
| | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* Restore the behaviour of the compatibility layer for integer-like PKsRyuta Kamizono2017-02-041-0/+104
| | | | | | | | | | | | | | | | | | | | | The PR #27384 changed migration compatibility behaviour. ```ruby class CreateMasterData < ActiveRecord::Migration[5.0] def change create_table :master_data, id: :integer do |t| t.string :name end end end ``` Previously this migration created non-autoincremental primary key expected. But after the PR, the primary key changed to autoincremental, it is unexpected. This change restores the behaviour of the compatibility layer.
* Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-011-6/+1
| | | | | | | | | | | | | | | | | | | MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
* show correct class name in migration inherited directly erroryuuji.yaginuma2017-01-241-2/+3
| | | | Follow up to 249f71a
* SQLite: Foreign Key SupportRyuta Kamizono2017-01-172-9/+47
| | | | https://www.sqlite.org/foreignkeys.html
* Raises when `ActiveRecord::Migration` is inherited directly.Rafael Mendonça França2016-12-291-12/+6
|
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-293-15/+13
|
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-1/+1
|
* Translate NOT NULL violation to the specific exceptionRyuta Kamizono2016-12-061-7/+11
| | | | | Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted or updated because it would violate a not null constraint.
* Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-053-8/+13
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Merge pull request #26631 from kamipo/remove_duplicate_conditionMatthew Draper2016-10-061-3/+1
|\ | | | | Remove duplicated `unless current_adapter?(:SQLite3Adapter)` condition
| * Remove duplicated `unless current_adapter?(:SQLite3Adapter)` conditionRyuta Kamizono2016-09-271-3/+1
| | | | | | | | | | | | `test_native_decimal_insert_manual_vs_automatic` exists inside `unless current_adapter?(:SQLite3Adapter)`. This condition is duplicated.
* | `:text_too_big` column should be `:text`, not `:integer`Ryuta Kamizono2016-09-271-1/+1
|/
* improve error message when include assertions failMichael Grosser2016-09-162-5/+5
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Remove duplicated `elsif` branchRyuta Kamizono2016-09-111-2/+0
| | | | The `elsif` branch is completely duplicated with `else` branch.
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-4/+4
|
* Add three new rubocop rulesRafael Mendonça França2016-08-167-40/+40
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* revises most Lint/EndAlignment offensesXavier Noria2016-08-071-3/+4
| | | | Some case expressions remain, need to think about those ones.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-063-3/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-066-402/+402
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-1/+1
|
* modernizes hash syntax in activerecordXavier Noria2016-08-068-122/+122
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-0615-162/+162
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Oracle TIMESTAMP sql type is associated with Rails `DateTime` type nowYasuo Honda2016-07-201-8/+1
| | | | | | - Refer https://github.com/rsim/oracle-enhanced/pull/845 Remove `set_date_columns` which has been deprecated in Oracle enhanced adapter - Refer https://github.com/rsim/oracle-enhanced/pull/869
* Fix wrong test namePrathamesh Sonpatki2016-07-161-1/+1
| | | | - Followup of https://github.com/rails/rails/pull/23179
* Fix typo: accidently -> accidentally.Hendy Tanata2016-07-021-1/+1
|
* Add regression test for foreign key schema dump cachingeileencodes2016-07-011-0/+13
| | | | | | | | | | | | | | | | | | | | If you had a foreign key set and then decided to add `on_delete: :cascade` later in another migration that migration would run but wouldn't refresh the schema dump. The reason for this was because `create_table_info` caches the statement and sets it to be the same as the original declaration for the foreign key (without the `on_delete: :cascade`. PR #25307 ended up fixing this bug because it removes the check for `create_table_info` and relies on reading from `information_schema`. The fix however was intended to patch another bug. The reason this fixes the issue is we're no longer parsing the regex from the cached `create_table_info`. This regression test is to ensure that the issue does not return if we for some reason go back to using `create_table_info` to set the foreign keys.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-1/+1
| | | | | | | | 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.
* Merge pull request #24221 from gregmolnar/uuidKasper Timm Hansen2016-04-201-0/+7
|\ | | | | create_join_table should work with uuid
| * add column type option to create_join_table to support uuidGreg Molnar2016-03-171-0/+7
| |
* | `foreign_key` respects `table_name_prefix` and `table_name_suffix`Ryuta Kamizono2016-04-191-0/+30
| |
* | Add test to verify named unique index, when creating reference via add_referenceVipul A M2016-04-161-0/+5
|/
* Merge pull request #23419 from ↵Matthew Draper2016-02-231-1/+13
|\ | | | | | | | | prathamesh-sonpatki/fix-showing-of-deprecation-warning-for-legacy-migrations Correctly show deprecation warning for incompatible migrations