aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* [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.
* | `create_join_table` should respect `references` column typeRyuta Kamizono2017-02-281-7/+5
| | | | | | | | | | | | | | | | 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.
* | Merge pull request #25285 from ↵Rafael França2017-02-231-0/+1
|\ \ | | | | | | | | | | | | 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/+1
| | |
* | | Correctly dump native timestamp types for MySQLRyuta Kamizono2017-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) ```
* | | Improve `create_table force: true`Ryuta Kamizono2017-02-201-2/+2
| |/ |/| | | | | | | Extra `data_source_exists?(table_name)` is unneeded if `drop_table(table_name, if_exists: true)` directly.
* | Merge pull request #26655 from kamipo/fix_remove_expression_indexRafael França2017-02-131-12/+16
|\ \ | | | | | | Fix `remove_index` to be able to remove expression indexes
| * | Fix `remove_index` to be able to remove expression indexesRyuta Kamizono2016-12-251-12/+16
| | | | | | | | | | | | Fixes #26635, #26641.
* | | Deprecate passing `default` to `index_name_exists?`Ryuta Kamizono2017-02-131-0/+5
| | |
* | | The `default` arg of `index_name_exists?` makes to optionalRyuta Kamizono2017-02-131-6/+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.
* | | Schema dumping support for PostgreSQL interval typeRyuta Kamizono2017-02-121-1/+1
| |/ |/| | | | | Closes #27979
* | Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-091-1/+1
| | | | | | | | | | | | Column options are passed as an hash args then used as `options` hash in `add_column_options!`. Converting args to attributes is inconvinient for using options as an hash.
* | `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-071-2/+2
| | | | | | | | | | | | | | | | 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.
* | Deprecate `ColumnDumper#migration_keys`Ryuta Kamizono2017-02-071-1/+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/+4
| | | | | | | | | | | | `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-0/+10
| | | | | | | | | | This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
* | Remove `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-181-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | `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
* | Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-041-1/+3
| | | | | | | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* | Merge pull request #27441 from koic/quoted_insert_version_sqlKasper Timm Hansen2016-12-311-4/+4
|\ \ | | | | | | Add a quote to an SQL insert statement of schema migration
| * | Add a quote to an SQL insert statement of schema migrationKoichi ITO2016-12-231-4/+4
| | |
* | | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-1/+1
| | |
* | | Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-6/+6
| |/ |/| | | | | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* | Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-8/+7
| |
* | No need to nodoc private methodsAkira Matsuda2016-12-241-3/+3
|/
* Merge pull request #26687 from kamipo/fix_add_index_to_normalize_optionsMatthew Draper2016-12-061-0/+1
|\ | | | | Fix `add_index` to normalize column names and options
| * Fix `add_index` to normalize column names and optionsRyuta Kamizono2016-10-031-1/+2
| | | | | | | | | | | | | | | | | | | | Currently does not work the following code. ```ruby add_index(:people, ["last_name", "first_name"], order: { last_name: :desc, first_name: :asc }) ``` Normalize column names and options to fix the issue.
* | Don't try to run multiple insert queries at onceSean Griffin2016-12-051-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | SQLite's default query interface ignores anything after the first semicolon in a query. This is actually quite common behavior in database drivers, especially when dealing with code paths for prepared statements (which we are). While this should only affect SQLite, as I'm not aware of any drivers which don't support multi-insert. Even if this does affect other third party drivers though, I'd prefer not to assume that more than one query can be executed per call to `execute`. Fixes #26948. Close #27242.
* | Merge pull request #26688 from kamipo/remove_respond_to_indexesKasper Timm Hansen2016-10-281-4/+0
|\ \ | | | | | | Remove unnecessary `respond_to?(:indexes)` checking
| * | Remove unnecessary `respond_to?(:indexes)` checkingRyuta Kamizono2016-10-031-4/+0
| |/ | | | | | | | | | | | | | | | | | | Currently all adapters (postgresql, mysql2, sqlite3, oracle-enhanced, and sqlserver) implemented `indexes` and schema dumper expects implemented `indexes`. https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/schema_dumper.rb#L208 Therefore `respond_to?(:indexes)` checking is unnecessary.
* | Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-261-1/+1
| | | | | | | | Follow up to 99cf7558000090668b137085bfe6bcc06c4571dc.
* | `name` is not a column optionRyuta Kamizono2016-10-101-1/+1
| | | | | | | | `migration_keys` includes `name` but `name` is not a column option.
* | Dump index options to pretty formatRyuta Kamizono2016-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | ```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
* | Prevent to create blank commentRyuta Kamizono2016-10-081-2/+2
|/ | | | | Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank.
* fix typo in `add_column` doc [ci skip]yuuji.yaginuma2016-09-161-1/+1
|
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-2/+2
|
* Added nil case handling to allow rollback migration in case oftravis.h.oneill@gmail.com2016-08-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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