aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* better `add_reference` documentation. [ci skip]Yves Senn2015-05-181-7/+13
| | | | | | | | | 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.
* More exercise the create index sql testsRyuta Kamizono2015-05-041-2/+2
|
* Correctly dump `:options` on `create_table` for MySQLRyuta Kamizono2015-05-031-0/+4
|
* Nodoc validate_index_length! methodPrathamesh Sonpatki2015-04-301-1/+1
| | | | - This method is used only by adapters to validate length of new index names.
* use a more descriptive example. [ci skip]Yves Senn2015-04-241-6/+4
| | | | follow up to 107526e809ea2b6de8b2775ecf83e55d60833206
* docs for `create_table` and non-int primary keys. [ci skip]Yves Senn2015-04-241-0/+17
|
* Document that partial indexes are only supported by Postgres and SQLite.Grey Baker2015-04-131-0/+2
| | | | Fixes #18106
* Add a note regarding add_column restricted API [ci skip]Zachary Scott2015-04-121-0/+4
| | | | | | We should document current behavior, and this is design of API for now. Closes #17597
* fix documentation for SchemaStatements#add_foreign_keySimon Stemplinger2015-04-081-2/+2
| | | | | | The implementation of the generation of the foreign key name was changed between Rails 4.2.0 and 4.2.1 from a random to a deterministic behavior, however the documentation still describes the old randomized behavior.
* No need to document drop_table in the PostgreSQLAdapterRafael Mendonça França2015-04-061-0/+3
| | | | | | It behaves in the same way that the abstract adapter. [ci skip]
* use singular table name if pluralize_table_names is setted as false while ↵Mehmet Emin İNAÇ2015-04-061-1/+4
| | | | | | | | | | | | | | 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
* [ci skip] Remove unacceptable method nameyui-knk2015-03-241-1/+1
|
* Tiny documentation edits [ci skip]Robin Dupret2015-02-241-1/+1
|
* Allow `:precision` option for time type columnsRyuta Kamizono2015-02-201-0/+6
|
* Revert "Allow `:precision` option for time type columns"Sean Griffin2015-02-171-6/+0
| | | | | | | | | | This reverts commit 1502caefd30b137fd1a0865be34c5bbf85ba64c1. The test suite for the mysql adapter broke when this commit was used with MySQL 5.6. Conflicts: activerecord/CHANGELOG.md
* Merge pull request #18662 from estum/foreign-key-existsYves Senn2015-02-161-15/+26
|\ | | | | | | Add `foreign_key_exists?` method.
| * Add methods to get foreign key matching argumentsAnton2015-01-291-40/+28
| |
| * Add `foreign_key_exists?` method.Anton2015-01-241-0/+23
| |
* | fix, `to_table` in `remove_foreign_key` should be plural.Yves Senn2015-02-161-1/+1
| |
* | Allow `:precision` option for time type columnsRyuta Kamizono2015-02-121-0/+6
| |
* | fix `remove_reference` with `foreign_key: true` on MySQL. #18664.Yves Senn2015-02-111-0/+6
| | | | | | | | | | | | | | | | | | | | MySQL rejects to remove an index which is used in a foreign key constraint: ``` ActiveRecord::StatementInvalid: Mysql2::Error: Cannot drop index 'index_copies_on_title_id': needed in a foreign key constraint: ALTER TABLE `copies` DROP `title_id` ``` Removing the constraint before removing the column (and the index) solves this problem.
* | Generate consistent names for foreign keysChris Sinjakli2015-02-031-1/+5
|/
* Add an `:if_exists` option to `drop_table`Stefan Kanev2015-01-191-1/+1
| | | | | | | | | | | If set to `if_exists: true`, it generates a statement like: DROP TABLE IF EXISTS posts This syntax is supported in the popular SQL servers, that is (at least) SQLite, PostgreSQL, MySQL, Oracle and MS SQL Sever. Closes #16366.
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-2/+2
|
* Add default value for `create_table_definition`Ryuta Kamizono2015-01-031-2/+2
| | | | | In most cases, `create_table_definition` called by table_name (the first argument) only.
* Extract the index length validation to a auxiliar methodRafael Mendonça França2014-12-301-3/+8
|
* Refactor a common class to reduce the duplication for `references`Sean Griffin2014-12-231-30/+2
| | | | | | | | 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-1/+16
| | | | | | | | | | | 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)
* Convert `add_references` to use kwargsSean Griffin2014-12-221-6/+18
| | | | | | While we still aren't accepting PRs that only make changes like this, it's fine when we're actively working on a method if it makes our lives easier.
* Add a `foreign_key` option to `references` while creating the tableSean Griffin2014-12-221-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* `force: :cascade` to recreate tables referenced by foreign-keys.Yves Senn2014-12-191-2/+7
|
* Failure to rollback t.timestamps when within a change_table migrationnoam2014-12-031-1/+1
| | | | | | | | | | | | | 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.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* raise a better exception for renaming long indexesAaron Patterson2014-11-201-0/+3
|
* synchronize code and docs for `timestamps` and `add_timestamps`.Yves Senn2014-11-201-2/+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)
* Support symbol foreign key to deletedtaniwaki2014-11-191-1/+1
|
* 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
* Merge pull request #16481 from sgrif/sg-change-default-timestampsDavid Heinemeier Hansson2014-08-171-3/+3
|\ | | | | Change the default `null` value for timestamps
| * Change the default `null` value for timestampsSean Griffin2014-08-121-3/+3
| | | | | | | | | | | | | | 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.
* | `index_exists?` with `:name` checks specified columns.Yves Senn2014-08-131-7/+8
|/ | | | | | | | | | | | | | | [Yves Senn & Matthew Draper] The column check was embodied in the defaul index name. If the :name option was used, the specified columns were not verified at all. Given: ``` assert connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_yo_momma) ``` That index could have been defined on any field, not necessarily on `:foo_id`.
* Merge pull request #16231 from Envek/type_in_referencesYves Senn2014-07-221-2/+9
|\ | | | | | | | | | | * 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/+2
|/ | | | [Andrey Novikov & Łukasz Sarnacki]
* fk: add docsYves Senn2014-06-261-0/+58
|
* fk: review corrections: indent, visibility, syntax, wording.Yves Senn2014-06-261-8/+9
|
* fk: use random digest namesYves Senn2014-06-261-8/+12
| | | | | | 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: `add/remove_foreign_key` are noop for adapters that don't support fkYves Senn2014-06-261-0/+4
|
* fk: raise when identifiers are longer than `allowed_index_name_length`.Yves Senn2014-06-261-1/+5
|
* fk: support for on_updateYves Senn2014-06-261-1/+2
|
* fk: rename `dependent` to `on_delete`Yves Senn2014-06-261-1/+1
|
* fk: infere column name from table names.Yves Senn2014-06-261-4/+14
| | | | This allows to create and remove foreign keys without specifying a column.