aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix doc of limit option for a text column [ci skip]Ryuta Kamizono2015-09-141-2/+2
| | | | | | | | | Follow up #21591. The document of limit option for a text column is incorrect. MySQL: the limit is byte length, not character length Pg, Sqlite3: variable unlimited length
* Merge pull request #21282 from sjain1107/added_docsYves Senn2015-08-191-0/+3
|\ | | | | | | Added docs for TableDefinition #coloumns & #remove_column [ci skip]
| * Added docs for TableDefinition #coloumns & #remove_column [ci skip]sjain11072015-08-181-0/+3
|/
* Add reversible syntax for change_column_defaultPrem Sichanugrist2015-06-261-2/+3
| | | | | | | | | | | | | Passing `:from` and `:to` to `change_column_default` makes this command reversible as user has defined its previous state. So, instead of having the migration command as: change_column_default(:posts, :state, "draft") They can write it as: change_column_default(:posts, :state, from: nil, to: "draft")
* Remove unused already requireRyuta Kamizono2015-05-191-4/+0
|
* better `add_reference` documentation. [ci skip]Yves Senn2015-05-181-13/+5
| | | | | | | | | This patch - reduces the duplication among the `reference`-family methods. - better explains all the optians available for `add_reference`. - redirects to user from `references` to `add_reference`. Originated by #20184.
* Remove redundant require 'set' linesMehmet Emin İNAÇ2015-05-151-1/+0
|
* Merge pull request #19978 from kamipo/collation_option_support_for_postgresqlRafael Mendonça França2015-05-031-1/+2
|\ | | | | PostgreSQL: `:collation` support for string and text columns
| * Move the collation handling code from the MySQL adapter to common classesRyuta Kamizono2015-05-041-1/+2
| | | | | | | | | | Some databases like MySQL allow defining collation charset for specific columns.
* | Merge pull request #19989 from kamipo/change_visit_addcolumn_visibiltyRafael Mendonça França2015-05-031-1/+4
|\ \ | | | | | | Change the `visit_AddColumn` visiblity for the internal API
| * | Change the `visit_AddColumn` visiblity for the internal APIRyuta Kamizono2015-05-031-1/+4
| |/
* / Missing `:bigint` [ci skip]Ryuta Kamizono2015-05-041-1/+1
|/
* Fix missing index when using timestamps with indexPaul Mucur2015-04-151-0/+1
| | | | | | | | | | | The `index` option used with `timestamps` should be passed to both `column` definitions for `created_at` and `updated_at` rather than just the first. This was happening because `Hash#delete` is used to extract the `index` option passed to `timestamps`, thereby mutating the `options` hash in-place. Now take a copy of the `options` before deleting so that the original is not modified.
* use singular table name if pluralize_table_names is setted as false while ↵Mehmet Emin İNAÇ2015-04-061-1/+1
| | | | | | | | | | | | | | creating foreign key test case for use singular table name if pluralize_table_names is setted as false while creating foreign key refactor references foreign key addition tests use singular table name while removing foreign key merge foreign key singular table name methods remove unnecessary drop table from test
* Merge pull request #19171 from JuanitoFatas/doc/more-examplesSean Griffin2015-03-021-0/+16
|\ | | | | Add more documents for AR connection_adapters abstract schema_definitions. [ci skip]
| * Add more documents for AR connection_adapters abstract schema_definitions. ↵Juanito Fatas2015-03-031-0/+16
| | | | | | | | | | | | | | | | | | [ci skip] - Add example to column_exists? - Add example to index_exists? - Add document for foreign_key - Add document for foreign_key_exists?
* | Clarify that t.references and t.belongs_to are interchangeable. [ci skip]Juanito Fatas2015-03-021-1/+1
|/
* Extract the short-hand methods into `ColumnMethods`Ryuta Kamizono2015-02-231-23/+28
|
* Extract `primary_key` method into `ColumnMethods`Ryuta Kamizono2015-02-221-6/+13
|
* Merge pull request #18662 from estum/foreign-key-existsYves Senn2015-02-161-0/+12
|\ | | | | | | Add `foreign_key_exists?` method.
| * Add methods to get foreign key matching argumentsAnton2015-01-291-0/+8
| |
| * Add `foreign_key_exists?` method.Anton2015-01-241-0/+4
| |
* | Remove `cast_type` in `ColumnDefinition`Ryuta Kamizono2015-02-111-1/+1
|/ | | | This is no longer needed.
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-15/+3
|
* Refactor `visit_ChangeColumnDefinition`Ryuta Kamizono2015-01-031-1/+1
| | | | `visit_ChangeColumnDefinition` is the same "CHANGE column_name " + `visit_ColumnDefinition(o)`.
* Minor documentation edits [ci skip]Robin Dupret2014-12-281-6/+5
|
* Add bigint primary key support for MySQL.Ryuta Kamizono2014-12-281-1/+2
| | | | | | | Example: create_table :foos, id: :bigint do |t| end
* reduce duplication in `ConnectionAdapters::Table` docs. [ci skip]Yves Senn2014-12-271-27/+38
| | | | | | Most of the documentation very closely mirrors the matching docs from `SchemaStatements`. I reduced duplicated copy and added links to the underlying methods for the user to follow.
* Refactor a common class to reduce the duplication for `references`Sean Griffin2014-12-231-29/+84
| | | | | | | | The code for `TableDefinition#references` and `SchemaStatements#add_reference` were almost identical both structurally, and in terms of domain knowledge. This removes that duplication into a common class, using the `Table` API as the expected interface of its collaborator.
* Add `foreign_key` as an option to `references` for `change_table`Sean Griffin2014-12-221-3/+6
| | | | | | | | | | | This has the same comments as 9af90ffa00ba35bdee888e3e1ab775ba0bdbe72c, however it affects the `add_reference` method, and `t.references` in the context of a `change_table` block. There is a lot of duplication of code between creating and updating tables. We should re-evaluate the structure of this code from a high level so changes like this don't need to be made in two places. (Note to self)
* Add a `foreign_key` option to `references` while creating the tableSean Griffin2014-12-221-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than having to do: create_table :posts do |t| t.references :user end add_foreign_key :posts, :users You can instead do: create_table :posts do |t| t.references :user, foreign_key: true end Similar to the `index` option, you can also pass a hash. This will be passed as the options to `add_foreign_key`. e.g.: create_table :posts do |t| t.references :user, foreign_key: { primary_key: :other_id } end is equivalent to create_table :posts do |t| t.references :user end add_foreign_key :posts, :users, primary_key: :other_id
* Convert `references` to kwargsSean Griffin2014-12-221-7/+17
| | | | | | While we aren't taking PRs with these kinds of changes just yet, they are fine if we're actively working on the method and it makes things easier.
* Failure to rollback t.timestamps when within a change_table migrationnoam2014-12-031-2/+2
| | | | | | | | | | | | | When running the following migration: change_table(:table_name) { |t| t/timestamps } The following error was produced: wrong number of arguments (2 for 1) .... /connection_adapters/abstract/schema_statements.rb:851:in `remove_timestamps' This is due to `arguments` containing an empty hash as its second argument.
* synchronize code and docs for `timestamps` and `add_timestamps`.Yves Senn2014-11-201-6/+5
| | | | | | | | This makes the following changes: * warn if `:null` is not passed to `add_timestamps` * `timestamps` method docs link to `add_timestamps` docs * explain where additional options go * adjust examples to include `null: false` (to prevent deprecation warnings)
* add a Table#name accessor like TableDefinition#nameCody Cutrer2014-11-101-17/+19
|
* docs, the abstract data type `:timestamp` was removed. See #15184 [ci skip]Yves Senn2014-11-071-2/+2
|
* edit pass over all warningsXavier Noria2014-10-281-4/+3
| | | | | | | | | | | | | | | This patch uniformizes warning messages. I used the most common style already present in the code base: * Capitalize the first word. * End the message with a full stop. * "Rails 5" instead of "Rails 5.0". * Backticks for method names and inline code. Also, converted a few long strings into the new heredoc convention.
* let's warn with heredocsXavier Noria2014-10-281-5/+6
| | | | | | | | | | | | The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
* Use type column first in multi-column indexesDerek Prior2014-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | `add_reference` can very helpfully add a multi-column index when you use it to add a polymorphic reference. However, the first column in the index is the `id` column, which is less than ideal. The [PostgreSQL docs][1] say: > A multicolumn B-tree index can be used with query conditions that > involve any subset of the index's columns, but the index is most > efficient when there are constraints on the leading (leftmost) > columns. The [MySQL docs][2] say: > MySQL can use multiple-column indexes for queries that test all the > columns in the index, or queries that test just the first column, the > first two columns, the first three columns, and so on. If you specify > the columns in the right order in the index definition, a single > composite index can speed up several kinds of queries on the same > table. In a polymorphic relationship, the type column is much more likely to be useful as the first column in an index than the id column. That is, I'm more likely to query on type without an id than I am to query on id without a type. [1]: http://www.postgresql.org/docs/9.3/static/indexes-multicolumn.html [2]: http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
* we don't need a HWIA and a hash allocated for just one k/v pairAaron Patterson2014-10-151-5/+3
|
* just look up the primary key from the columns hashAaron Patterson2014-10-151-6/+1
|
* add table.bigint supportAaron Patterson2014-10-151-1/+1
| | | | | | | | In the DSL you can now do: create_table(:foos) do |t| t.bigint :hi end
* Merge pull request #16781 from kamipo/move_column_option_handlingYves Senn2014-09-031-1/+0
|\ | | | | Move column option handling to new_column_definition
| * Move column option handling to new_column_definitionRyuta Kamizono2014-09-031-1/+0
| | | | | | | | | | TableDefinition#column is not called from `add_column`. Use TableDefinition#new_column_definition for column option handling.
* | Add and Remove string/strip requireArthur Neves2014-09-021-1/+0
|/ | | | | | | Method .strip_heredoc is defined in active_support/core_ext/string/strip.rb so we need to require it. [fixes #16677]
* Avoid using heredoc for user warningsGodfrey Chan2014-08-281-6/+5
| | | | | | | | | | Using heredoc would enforce line wrapping to whatever column width we decided to use in the code, making it difficult for the users to read on some consoles. This does make the source code read slightly worse and a bit more error-prone, but this seems like a fair price to pay since the primary purpose for these messages are for the users to read and the code will not stick around for too long.
* Add missing AS requireArthur Neves2014-08-191-0/+1
| | | | `strip_heredoc` method is defined on active_support/core_ext/string
* Change the default `null` value for timestampsSean Griffin2014-08-121-3/+21
| | | | | | | As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
* Merge pull request #16231 from Envek/type_in_referencesYves Senn2014-07-221-2/+16
|\ | | | | | | | | | | * Allow to specify a type for foreign key column in migrations * unified the docs * some cleanup in CHANGELOG
| * Allow to specify a type for foreign key column in migrationsAndrey Novikov2014-07-221-1/+8
|/ | | | [Andrey Novikov & Łukasz Sarnacki]