aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Add array column documentationoss922016-08-161-0/+4
|
* Merge pull request #26155 from kamipo/refactor_quoted_columns_for_indexRafael Mendonça França2016-08-161-13/+16
|\ | | | | | | Refactor `quoted_columns_for_index` by extracted `add_options_for_index_columns`
| * Refactor `quoted_columns_for_index` by extracted `add_options_for_index_columns`Ryuta Kamizono2016-08-141-13/+16
| |
* | Merge pull request #26019 from agrobbin/schema-load-unique-column-indicesRafael França2016-08-161-1/+1
|\ \ | | | | | | Support multiple indexes on the same column when loading the schema
| * | support multiple indexes on the same column when loading the schemaAlex Robbin2016-08-021-1/+1
| | |
* | | Add three new rubocop rulesRafael Mendonça França2016-08-161-10/+10
| |/ |/| | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | Fix a NoMethodError schema_statements.rbGenadi Samokovarov2016-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you call `remove_index` with wrong options, say a type, like I did, you get: ``` == 20160810072541 RemoveUniqueIndexOnGoals: migrating ========================= -- remove_index(:goal, {:coulmn=>:kid_id, :unique=>true}) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: undefined method `ArgumentError' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x007fb7dec91b28> ``` What happened is that I mistyped column (coulmn) and got a `NoMethodError`, because of a missing comma during the raise. This made Ruby think we're calling the method `ArgumentError`.
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-061-32/+32
| |
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
| |
* | applies new string literal convention in activerecord/libXavier Noria2016-08-061-9/+9
| | | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-08-021-1/+1
|\ \ | |/ |/|
| * Fix documentation of `index` option for the `add_reference` method [ci skip]Prathamesh Sonpatki2016-07-161-1/+1
| | | | | | | | - Followup of https://github.com/rails/rails/pull/23179.
* | Merge pull request #25578 from ↵Rafael França2016-07-201-8/+3
|\ \ | | | | | | | | | | | | kamipo/move_warning_about_composite_primary_key_to_attribute_methods_primary_key Move the warning about composite primary key to `AttributeMethods::PrimaryKey`
| * | Move the warning about composite primary key to `AttributeMethods::PrimaryKey`Ryuta Kamizono2016-07-021-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually schema dumper/creation supports composite primary key (#21614). Therefore it should not show the warning about composite primary key in connection adapter. This change moves the warning to `AttributeMethods::PrimaryKey` and suppress the warning for habtm join table. Fixes #25388.
* | | Add newline between each migration in `structure.sql`Grey Baker2016-07-141-2/+2
| |/ |/| | | | | | | | | Keeps schema migration inserts as a single commit, so we still get all of the benefits of https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a78, but allows for easier git diff-ing. Fixes #25504.
* | [ci skip] Update documentation in AR SchemaStatementsAlex Kitchens2016-07-071-12/+12
|/ | | | This includes minor grammar fixes throughout the file.