aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* Bump minimum SQLite version to 3.8Yasuo Honda2018-05-211-7/+1
| | | | | | | | | | | | | | These OS versions have SQLite 3.8 or higher by default. - macOS 10.10 (Yosemite) or higher - Ubuntu 14.04 LTS or higher Raising the minimum version of SQLite 3.8 introduces these changes: - All of bundled adapters support `supports_multi_insert?` - SQLite 3.8 always satisifies `supports_foreign_keys_in_create?` and `supports_partial_index?` - sqlite adapter can support `alter_table` method for foreign key referenced tables by #32865 - Deprecated `supports_multi_insert?` method
* Restore original merging order to enforce `if_exists: true`Ryuta Kamizono2018-04-291-2/+1
| | | | | The merging order was accidentally changed at #32447. The original intention is force `drop_table ... if_exists: true`. #28070.
* passing splat keyword arguments as a single Hashutilum2018-04-041-2/+3
| | | | Ruby 2.6.0 warns about this.
* Remove `ForeignKeys` module which was introduced at #32299Ryuta Kamizono2018-04-021-1/+1
| | | | | | | To solve the problem #32299, just enough to introduce `fk_ignore_pattern` option. I don't think there is a need to expose these constants.
* Expose foreign key name ignore pattern in configurationDavid Stosik2018-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When dumping the database schema, Rails will dump foreign key names only if those names were not generate by Rails. Currently this is determined by checking if the foreign key name is `fk_rails_` followed by a 10-character hash. At [Cookpad](https://github.com/cookpad), we use [Departure](https://github.com/departurerb/departure) (Percona's pt-online-schema-change runner for ActiveRecord migrations) to run migrations. Often, `pt-osc` will make a copy of a table in order to run a long migration without blocking it. In this copy process, foreign keys are copied too, but [their name is prefixed with an underscore to prevent name collision ](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#cmdoption-pt-online-schema-change-alter-foreign-keys-method). In the process described above, we often end up with a development database that contains foreign keys which name starts with `_fk_rails_`. That name does not match the ignore pattern, so next time Rails dumps the database schema (eg. when running `rake db:migrate`), our `db/schema.rb` file ends up containing those unwanted foreign key names. This also produces an unwanted git diff that we'd prefer not to commit. In this PR, I'd like to suggest a way to expose the foreign key name ignore pattern to the Rails configuration, so that individual projects can decide on a different pattern of foreign keys that will not get their names dumped in `schema.rb`.
* PostgreSQL adapter also supports bulk alter since #31331 [ci skip]yuuji.yaginuma2018-03-021-1/+1
|
* Update note on MySQL index order support [ci skip]Eugene Kenny2018-01-261-1/+1
| | | | | MySQL supports descending indexes from 8.0.1 onwards: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-1.html
* 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.
* Extract duplicated index column options normalization as ↵Ryuta Kamizono2017-12-031-9/+10
| | | | | | | `options_for_index_columns` And placed `add_options_for_index_columns` in `schema_statements.rb` consistently to ease to find related code.
* Refactor `length`, `order`, and `opclass` index options dumpingRyuta Kamizono2017-12-031-1/+1
|
* Merge pull request #31230 from dinahshi/postgresql_extract_sqlMatthew Draper2017-12-031-1/+15
|\ | | | | Extract sql fragment generators from PostgreSQL adapter
| * Extract sql fragment generators for alter table from PostgreSQL adapterDinah Shi2017-12-021-1/+15
| |
* | Add support for invalid foreign keys in PostgresTravis Hunter2017-12-011-0/+2
| | | | | | | | Add validate_constraint and update naming
* | Remove unpaired `}` [ci skip]Ryuta Kamizono2017-12-011-2/+1
| |
* | Add support for PostgreSQL operator classes to add_indexGreg Navis2017-11-301-2/+26
|/ | | | | | | | | | | | Add support for specifying non-default operator classes in PostgreSQL indexes. An example CREATE INDEX query that becomes possible is: CREATE INDEX users_name ON users USING gist (name gist_trgm_ops); Previously it was possible to specify the `gist` index but not the custom operator class. The `add_index` call for the above query is: add_index :users, :name, using: :gist, opclasses: {name: :gist_trgm_ops}
* [ci skip]Update the documentation about the primary key typesuginoy2017-10-291-15/+15
| | | | | | Replace the primary key type `integer` in docs with `bigint`. ref #26266
* Remove deprecated argument `name` from `#indexes`Rafael Mendonça França2017-10-231-1/+1
|
* Remove deprecated methods `initialize_schema_migrations_table` and ↵Rafael Mendonça França2017-10-231-10/+0
| | | | `initialize_internal_metadata_table`
* Remove deprecated argument `default` from `index_name_exists?`Rafael Mendonça França2017-10-231-6/+1
|
* [Active Record] require => require_relativeAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* Express #change_column_comment as public apibogdanvlviv2017-10-041-1/+1
| | | | | Implemented by #22911 Related to #30677
* Preload digest/sha2 to avoid thread safe error.Francesco Rodriguez2017-09-251-1/+1
| | | | | | | | | | | | | | | | I got this error in production using Puma in multi-threaded mode: ``` RuntimeError: Digest::Base cannot be directly inherited in Ruby from active_support/security_utils.rb:23:in `variable_size_secure_compare' from active_support/security_utils.rb:23:in `hexdigest' from active_support/security_utils.rb:23:in `digest' ``` Looks like Digest uses const_missing to load Digest::SHA256 (https://github.com/ruby/ruby/blob/trunk/ext/digest/lib/digest.rb#L8) - https://bugs.ruby-lang.org/issues/9494 - https://github.com/ruby/ruby/commit/c02fa39463a0c6bf698b01bc610135604aca2ff4
* Add :comment option for add_column [ci skip]Yoshiyuki Kinjo2017-09-201-0/+2
|
* Clarify that bulk option is supported only by MySQL [ci skip]Prathamesh Sonpatki2017-08-291-0/+2
| | | | - Closes #30441
* Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-221-0/+4
| | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
* [ci skip] Postgres --> PostgreSQLRyuta Kamizono2017-08-081-1/+1
|
* Clarify add_column limit documentationLisa Ugray2017-07-251-0/+1
| | | | | The limit option is ignored by PostgreSQL and may be ignored by 3rd party backends. Make this clear in the docs. Fixes #29922.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-7/+7
|\
| * 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.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-1/+1
| |\ \ | | | | | | | | | | | | Make ActiveSupport frozen-string-literal friendly.
| | * | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-1/+1
| | |/
| * / Don't cache queries for schema statementsRyuta Kamizono2017-06-301-6/+6
| |/ | | | | | | | | | | `test_middleware_caches` is sometimes failed since #29454. The failure is due to schema statements are affected by query caching. Bypassing query caching for schema statements to avoid the issue.
* / [Active Record] require => require_relativeAkira Matsuda2017-07-011-1/+1
|/
* Fix `dump_schema_information` with empty versionsRyuta Kamizono2017-06-151-1/+1
| | | | Fixes #29460.
* Remove `null_allowed` option from doc [ci skip]yuuji.yaginuma2017-06-101-2/+1
| | | | This option was added in b9fa354. But it does not seem to work.
* [ci skip] Add missing `be`Prathamesh Sonpatki2017-06-031-1/+1
|
* Merge pull request #29135 from ↵Eileen M. Uchitelle2017-06-021-0/+19
|\ | | | | | | | | Nerian/document_support_for_composite_primary_keys Document support for composite primary keys
| * Document support for composite primary keysNerian2017-05-181-0/+19
| |
* | [Foreign Key] Don't worry about the building identifier if name is already ↵Mohit Natoo2017-05-101-2/+3
|/ | | | present.
* Make internal methods to privateRyuta Kamizono2017-03-271-23/+46
|
* Remove duplicated `columns` definitionRyuta Kamizono2017-03-201-3/+5
|
* Merge pull request #28068 from kamipo/refactor_data_sourcesRafael França2017-03-131-2/+18
|\ | | | | Extract `data_source_sql` to refactor data source statements
| * Extract `data_source_sql` to refactor data source statementsRyuta Kamizono2017-02-201-2/+18
| |
* | Extract `SchemaMigration.all_versions`Ryuta Kamizono2017-03-061-2/+2
| | | | | | | | | | Use `SchemaMigration.all_versions` instead of `SchemaMigration.all.map(&:version)` to avoid to instantiate AR objects.
* | Remove useless `Migrator.schema_migrations_table_name`Ryuta Kamizono2017-03-051-2/+2
| | | | | | | | Simply use `SchemaMigration.table_name` instead.
* | Don't hide method that's been documented API since Rails 2.1Andrew White2017-03-041-3/+3
| |
* | Fix `rake db:schema:load` with subdirectoriesRyuta Kamizono2017-03-051-5/+4
| | | | | | | | | | | | | | | | Related #25174. `db:schema:load` doesn't work with subdirectories like previous `db:migrate:status`. `Migrator.migration_files` should be used in `assume_migrated_upto_version` to fix the issue.