aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* 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]
* Always pass a column with a type object to quoteSean Griffin2014-06-281-1/+1
| | | | | | | | The only case where we got a column that was not `nil`, but did not respond to `cast_type` was when type casting the default value during schema creation. We can look up the cast type, and add that object to the column definition. Will allow us to consistently rely on the type objects for type casting in all directions.
* Add nodoc to internal class [ci skip]Rafael Mendonça França2014-06-261-1/+1
|
* fk: use random digest namesYves Senn2014-06-261-1/+10
| | | | | | The name of the foreign key is not relevant from a users perspective. Using random names resolves the urge to rename the foreign key when the respective table or column is renamed.
* fk: support for on_updateYves Senn2014-06-261-0/+4
|
* fk: rename `dependent` to `on_delete`Yves Senn2014-06-261-2/+2
|
* fk: support dependent option (:delete, :nullify and :restrict).Yves Senn2014-06-261-0/+4
|
* fk: generalize using `AlterTable` and `SchemaCreation`.Yves Senn2014-06-261-0/+12
|
* fk: `foreign_keys`, `add_foreign_key` and `remove_foreign_key` for MySQLYves Senn2014-06-261-0/+14
|
* Change wording of explanation about precision & scale of decimal numbers [ci ↵Prathamesh Sonpatki2014-06-041-2/+2
| | | | skip]
* Remove :timestamp column typeSean Griffin2014-05-191-0/+7
| | | | | | | | | | | | The `:timestamp` type for columns is unused. All database adapters treat them as the same database type. All code in `ActiveRecord` which changes its behavior based on the column's type acts the same in both cases. However, when the type is passed to code that checks for the `:datetime` type, but not `:timestamp` (such as XML serialization), the result is unexpected behavior. Existing schema definitions will continue to work, and the `timestamp` type is transparently aliased to `datetime`.
* Make `:index` in migrations work with all column typesMarc Schütz2014-05-181-6/+13
|
* Remove dead test code for unsupported adaptersSean Griffin2014-05-171-9/+0
|
* fix bug on non empty defaults for pg array columnsLuke Steensen2014-03-301-1/+1
| | | | fixes #10613
* support creating temporary tables from queriesCody Cutrer2013-12-141-2/+3
| | | | | also override drop_table in AbstractMySQLAdapter to properly drop temporary tables without committing the transaction
* Remove redundant `string_to_binary` from type-castingVipul A M2013-08-091-3/+0
|
* Merge pull request #10425 from ↵Rafael Mendonça França2013-06-131-0/+3
|\ | | | | | | | | ranjaykrishna/push_add_column_options_to_schema_creation Push add column options to schema creation
| * Moving add_column_options! up to SchemaCreationjeran2013-06-121-0/+3
| | | | | | | | | | | | | | | | removed two instances of add_column_options! from abstract_mysql_adapter reworked rename_column_sql to remove add_column_options from schema_statements changed to use new hash syntax.
* | Fixes #10432 add_column not creating array columns in PostgreSQLAdam Anderson2013-06-041-0/+1
| | | | | | | | | | | | When then PostgreSQL visitor was [added](https://github.com/rails/rails/commit/6b7fdf3bf3675a14eae74acc5241089308153a34) `add_column` was no longer receiving the column options directly. This caused the options to be lost along the way.
* | Merge pull request #10572 from nertzy/dont-modify-options-hash-in-primary-keyRafael Mendonça França2013-05-111-2/+1
| | | | | | | | Don't modify args in TableDefinition#primary_key
* | Make references with index:true pass Hash options to add_index.Victor Costan2013-04-011-1/+1
|/
* Add support for FULLTEXT and SPATIAL indexes using the :type flag for MySQL.Ken Mazaika2013-03-271-1/+1
|
* Custom index type support with :using.doabit2013-03-241-1/+1
|
* add uuid primary key supportAaron Patterson2013-03-221-2/+3
|
* separate primary key from column typeAaron Patterson2013-03-221-10/+11
|
* push the mysql add_column up to the abstract adapterAaron Patterson2013-03-221-1/+3
|
* allow multiple add columnsAaron Patterson2013-03-221-4/+4
|