aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Reuse existing validate_index_length! methodPrathamesh Sonpatki2016-06-091-7/+7
| | | | - Followup of https://github.com/rails/rails/commit/1ea6cc11211dc89e3e14b2b641a3cca8a0a91d55.
* Respect options passed to `foreign_key` when reverting `add_reference`Sean Griffin2016-05-311-4/+9
| | | | | | | | | | | | The code incorrectly assumes that the option was written as `foreign_key: true`, but that is not always the case. This now mirrors the behavior of reverting `add_foreign_key`. The code was changed to use kwargs while I was touching it, as well. This could really use a refactoring to go through the same code paths as `add_refernce` in the future, so we don't duplicate default values. Fixes #25169
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-241-3/+17
| | | | | | | | | | | | | | | | Example: create_table :users do |t| t.string :name t.index 'lower(name) varchar_pattern_ops' end Fixes #19090. Fixes #21765. Fixes #21819. Fixes #24359. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* remove_index do not fetch indexes if name is specifiedSeva Orlov2016-04-241-1/+7
| | | | | | There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Add `:nodoc:` to `insert_versions_sql` [ci skip]Ryuta Kamizono2016-04-241-1/+1
| | | | Follow up to #24685. `insert_versions_sql` is not public API.
* Schema load: Fix dupe version insertJeremy Daer2016-04-221-1/+1
| | | | Re. 6e098284e97250eaed6f30f5c7c362d87da986b0
* https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a ↵Vipul A M2016-04-231-4/+16
| | | | | | | | | 78 changed INSERT INTO versions to run in 1 single query. This breaks for sqlite versions < 3.7.11, which is especially the case on Ubuntu 12.04 LTS, that has SQLite version 3.7.9 as default. So we check for support for multi insert, before performing single query inserts, else fallback to older version of running multiple queries. [Vipul A M & Yasuo Honda]
* Revert "add doc for `:type` option of `#create_join_table` [ci skip]"प्रथमेश Sonpatki2016-04-211-2/+0
|
* add doc for `:type` option of `#create_join_table` [ci skip]yuuji.yaginuma2016-04-211-0/+2
| | | | Follow up to #24221.
* Merge pull request #24221 from gregmolnar/uuidKasper Timm Hansen2016-04-201-2/+3
|\ | | | | create_join_table should work with uuid
| * add column type option to create_join_table to support uuidGreg Molnar2016-03-171-2/+3
| |
* | Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-181-15/+14
| | | | | | | | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* | Merge pull request #22911 from Envek/database_commentsJeremy Daer2016-04-161-6/+30
|\ \ | | | | | | | | | Add support for specifying comments for tables, columns, and indexes in database itself
| * | Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
* | | [ci skip] docs for add_references index optionAlex Handley2016-04-161-1/+10
|/ / | | | | | | | | | | - Add link for finding the addional options for index. - Add example for unique index as this is a common requirement. - Add link in guide for index options.
* / Fix description for method ↵Bogdan2016-03-271-2/+2
|/ | | | ActiveRecord::ConnectionAdapters::SchemaStatements#add_timestamps [ci skip]
* Fixed comments of add_foreign_key methodSalman Afzal Siddiqui2016-03-101-2/+2
| | | The comments of add_foreign_key method was displaying incorrect constraint name.
* Add numeric type in the doc [ci skip]Ryuta Kamizono2016-02-081-3/+3
| | | | Follow up to #23508.
* Merge pull request #23460 from ↵Sean Griffin2016-02-031-1/+1
|\ | | | | | | | | kamipo/innodb_supports_fulltext_and_spatial_indexes InnoDB supports FULLTEXT and Spatial Indexes [ci skip]
| * InnoDB supports FULLTEXT and Spatial Indexes [ci skip]Ryuta Kamizono2016-02-041-1/+1
| | | | | | | | | | https://dev.mysql.com/doc/refman/5.7/en/innodb-fulltext-index.html https://dev.mysql.com/doc/refman/5.7/en/creating-spatial-indexes.html
* | SQLite 2 support has been dropped [ci skip]Ryuta Kamizono2016-02-041-2/+0
|/
* Avoid extra `show variables` in migrationRyuta Kamizono2016-02-011-1/+5
| | | | | | | | | | | | | `initialize_schema_migrations_table` is called in every migrations. https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/migration.rb#L1080 https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/schema.rb#L51 This means that extra `show variables` is called regardless of the existence of `schema_migrations` table. This change is to avoid extra `show variables` if `schema_migrations` table exists.
* Merge pull request #23345 from ↵Rafael França2016-01-301-0/+6
|\ | | | | | | | | yui-knk/warning_when_composite_primary_key_is_detected Warn if `AR.primary_key` is called for a table who has composite prim…
| * Warn if `AR.primary_key` is called for a table who has composite primary keyyui-knk2016-01-301-0/+6
| | | | | | | | | | | | | | | | If `AR.primary_key` is called for a table who has composite primary key, the method returns `nil`. This behavior sometimes generates invalid SQL. The first time developers notice to invalid SQL is when they execute SQL. This commit enables developers to know they are doing something dangerous as soon as possible.
* | Merge pull request #23349 from kamipo/refactor_column_existsRafael França2016-01-301-7/+8
|\ \ | | | | | | Refactor `column_exists?` in `SchemaStatements`