aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-132-2/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Start Rails 6.1 developmentRafael Mendonça França2019-04-241-1/+4
|
* make change_column_comment and change_table_comment invertibleYoshiyuki Kinjo2019-04-152-1/+34
| | | | | | | | | We can revert migrations using `change_column_comment` or `change_table_comment` at current master. However, results are not what we expect: comments are remained in new status. This change tells previous comment to these methods in a way like `change_column_default`.
* Allow `remove_foreign_key` with both `to_table` and `options`Ryuta Kamizono2019-03-061-13/+4
| | | | | | | Foreign keys could be created to the same table. So `remove_foreign_key :from_table, :to_table` is sometimes ambiguous. This allows `remove_foreign_key` to remove the select one on the same table with giving both `to_table` and `options`.
* Avoid implicit delegation in the migration compatibilityRyuta Kamizono2019-02-121-12/+14
| | | | | | | The implicit delegation in the migration class is to be logged. It is not intended in the migration compatibility, so it should be avoided. Fixes #35224.
* Make `t.timestamps` with precision by defaultRyuta Kamizono2019-01-261-48/+47
|
* Fix type casting column default in `change_column`Ryuta Kamizono2019-01-201-3/+1
| | | | | | | | | | | | | | Since #31230, `change_column` is executed as a bulk statement. That caused incorrect type casting column default by looking up the before changed type, not the after changed type. In a bulk statement, we can't use `change_column_default_for_alter` if the statement changes the column type. This fixes the type casting to use the constructed target sql_type. Fixes #34938.
* Fix `transaction` reverting for migrationsfatkodima2018-09-262-1/+33
| | | | [fatkodima & David Verhasselt]
* Allow `to_table` in `invert_remove_foreign_key`Rich2018-08-141-3/+16
| | | | | | | | | | | | remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen]
* Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-1/+1
| | | | | Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
* Fix `Unknown migration version "6.0"`Yuji Yaginuma2018-01-311-1/+4
|
* Remove default ENGINE=InnoDB for Mysql2 adapterAlberto Almagro2017-12-111-0/+8
| | | | | | | | | | | | | Before this commit ENGINE=InnoDB was added by default to Mysql2 adapter +create_table+ if no +options+ option was provided. This default ENGINE was lost as soon as something was passed in at +options+ option, making its goal and propagation inconsistent, as the programmer needed to remember including ENGINE=InnoDB when something was passed in. This commit removes default ENGINE as its use isn't needed anymore for current MySQL and MariaDB versions. It adds compatibility support and tests to ensure that default ENGINE is still present for migrations with version 5.1 and before. It also ensures we still dump the ENGINE option to +schema.rb+ in order to avoid inconsistencies.
* `change_column_default` should be executed after type changingRyuta Kamizono2017-12-031-7/+10
| | | | | | | | | | | | | | | | | | | | If do not execute a type changing first, filling in default value may be failed. ``` % ARCONN=postgresql be ruby -w -Itest test/cases/migration/compatibility_test.rb -n test_legacy_change_column_with_null_executes_update Using postgresql Run options: -n test_legacy_change_column_with_null_executes_update --seed 20459 E Error: ActiveRecord::Migration::CompatibilityTest#test_legacy_change_column_with_null_executes_update: StandardError: An error has occurred, this and all later migrations canceled: PG::StringDataRightTruncation: ERROR: value too long for type character varying(5) : UPDATE "testings" SET "foo"='foobar' WHERE "foo" IS NULL ```
* Extract sql fragment generators for alter table from PostgreSQL adapterDinah Shi2017-12-021-0/+9
|
* Merge pull request #30510 from yhirano55/add_nodoc_to_activerecordEileen M. Uchitelle2017-11-251-1/+1
|\ | | | | Add :nodoc: to activerecord [ci skip]
| * Add :nodoc: to activerecord [ci skip]Yoshiyuki Hirano2017-09-031-1/+1
| |
* | compatibility - use int instead of bigintpavel2017-10-181-1/+1
| |
* | Extract repeatedly appeared prepending compatible table definitionRyuta Kamizono2017-10-051-25/+24
| |
* | Move integer-like primary key normalization to `new_column_definition`Ryuta Kamizono2017-09-231-7/+1
| | | | | | | | | | | | Currently the normalization only exists in `primary_key` shorthand. It should be moved to `new_column_definition` to also affect to `add_column` with primary key.
* | Adding legacy primary key should be compatibleRyuta Kamizono2017-09-231-0/+19
| | | | | | | | | | | | | | Currently implicit legacy primary key is compatible, but adding explicit legacy primary key is not compatible. It should also be fixed. Fixes #30664.
* | Use algorithm while removing index with db:rollbackMehmet Emin İNAÇ2017-09-211-2/+2
| | | | | | | | Closes #24190
* | make create_join_table compatible.Yuki Masutomi2017-09-201-0/+15
|/
* [ci skip] Postgres --> PostgreSQLRyuta Kamizono2017-08-081-1/+1
|
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-193-0/+6
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-023-3/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-013-0/+3
|
* `respond_to_missing?` should be privateRyuta Kamizono2017-04-221-6/+6
| | | | | | | Follow up of 03d3f036. Some of `respond_to?` were replaced to `respond_to_missing?` in 03d3f036. But the visibility is still public. It should be private.
* Start Rails 5.2 developmentMatthew Draper2017-03-221-1/+4
|
* The `default` arg of `index_name_exists?` makes to optionalRyuta Kamizono2017-02-131-2/+2
| | | | | | 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-071-1/+35
| | | | | | | | 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/+6
| | | | | | | | | | | | | | | | | | | | | 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.
* Tweak bigint PK handlingMatthew Draper2017-01-181-2/+1
| | | | | | * Don't force PKs on tables that have explicitly opted out * All integer-like PKs are autoincrement unless they have an explicit default
* Fix UUID primary key with default nil in legacy migrationRyuta Kamizono2017-01-091-1/+1
| | | | | | UUID primary key with no default value feature (#10404, #18206) was lost in legacy migration caused by #25395 got merged. Restore the feature again in legacy migration.
* Raises when `ActiveRecord::Migration` is inherited directly.Rafael Mendonça França2016-12-291-41/+21
|
* Remove unnecessary `connection_name` variableRyuta Kamizono2016-12-061-2/+1
|
* Make pg adapter use bigserial for pk by defaultPavel Pravosud2016-12-051-1/+11
|
* For `PostgreSQL >= 9.4` use `gen_random_uuid()`Yaw Boakye2016-11-221-0/+8
| | | | | | | | | | Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()` to generate version 4 UUIDs instead of the functions in the `uuid-ossp` extension. These changes uses the appropriate UUID function depending on the underlying PostgreSQL server's version, while maintaining `uuid_generate_v4()` in older migrations.
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-1/+1
| | | | | | 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.
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-031-4/+4
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* Override `respond_to_missing?` instead of `respond_to?` when possibleSean Griffin2016-08-311-1/+1
| | | | | | | | | | This was almost every case where we are overriding `respond_to?` in a way that mirrors a parallel implementation of `method_missing`. There is one remaining case in Active Model that should probably do the same thing, but had a sufficiently strange implementation that I want to investigate it separately. Fixes #26333.
* Avoid to allow unused splat args for `t.timestamps` in `create_table`Ryuta Kamizono2016-08-141-2/+2
| | | | | | Unfortunately `t.timestamps` in `create_table` allows unused splat args. But the same one in `change_table` does not allow them. This commit fixes the inconsistent behavior.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-063-106/+106
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add migration compatibility class for Rails 5.1Rafael Mendonça França2016-05-101-1/+4
|
* Migrations: move version-finding responsibilityyui-knk2016-04-291-0/+10
| | | | | | | `ActiveRecord::Migration` needn't know about migration version compatibility lookup. Delegate it to the Compatibility module. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Update compatibility.rbBogdan2016-03-261-1/+1
|
* Correctly show deprecation warning for incompatible migrationsPrathamesh Sonpatki2016-02-121-1/+1
|
* Intervene on change_table as well as create_tableMatthew Draper2016-01-301-0/+13
|
* Pare back default `index` option for the migration generatorPrathamesh Sonpatki2016-01-241-0/+12
| | | | | | | | | | - Using `references` or `belongs_to` in migrations will always add index for the referenced column by default, without adding `index:true` option to generated migration file. - Users can opt out of this by passing `index: false`. - Legacy migrations won't be affected by this change. They will continue to run as they were before. - Fixes #18146
* fix remove_index for postgresql when running legacy migrationsLachlan Sylvester2016-01-061-2/+3
|