aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
Commit message (Collapse)AuthorAgeFilesLines
* SQLite: Foreign Key SupportRyuta Kamizono2017-01-171-3/+3
| | | | https://www.sqlite.org/foreignkeys.html
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-4/+4
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-181-7/+9
| | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-0/+12
| | | | | | | | | | | | | 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
* Support for foreign keys in create tableRyuta Kamizono2015-09-201-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | If foreign keys specified in create table, generated SQL is slightly more efficient. Definition: ``` create_table :testings do |t| t.references :testing_parent, foreign_key: true end ``` Before: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer); ALTER TABLE "testings" ADD CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id"); ``` After: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer, CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id")); ```
* Merge pull request #21589 from ↵Jeremy Daer2015-09-191-2/+6
|\ | | | | | | | | | | kamipo/eliminate_duplicated_visit_table_definition Eliminate the duplication code of `visit_TableDefinition`
| * Eliminate the duplication code of `visit_TableDefinition`Ryuta Kamizono2015-09-161-5/+13
| |
* | Merge pull request #21608 from ↵Jeremy Daer2015-09-191-6/+4
|\ \ | | | | | | | | | | | | kamipo/eliminate_duplicated_options_include_default_method Eliminate the duplicated `options_include_default?` method
| * | Eliminate the duplicated `options_include_default?` methodRyuta Kamizono2015-09-131-6/+4
| |/ | | | | | | Follow up 7ba2cd06.
* / Correctly dump composite primary keyRyuta Kamizono2015-09-201-3/+10
|/ | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
* Merge pull request #19978 from kamipo/collation_option_support_for_postgresqlRafael Mendonça França2015-05-031-0/+1
|\ | | | | PostgreSQL: `:collation` support for string and text columns
| * Move the collation handling code from the MySQL adapter to common classesRyuta Kamizono2015-05-041-0/+1
| | | | | | | | | | Some databases like MySQL allow defining collation charset for specific columns.
* | Change the `visit_AddColumn` visiblity for the internal APIRyuta Kamizono2015-05-031-5/+5
|/
* Use `delegate` to call the methods to `@conn`Ryuta Kamizono2015-02-191-16/+3
|
* Refactor `quote_default_expression`Ryuta Kamizono2015-02-111-6/+1
| | | | | | | `quote_default_expression` and `quote_default_value` are almost the same handling for do not quote default function of `:uuid` columns. Rename `quote_default_value` to `quote_default_expression`, and remove duplicate code.
* An array type is a part of `sql_type`Ryuta Kamizono2015-02-081-1/+1
| | | | | | `sql_type` is reused in `lookup_cast_type`. If making it a part of `sql_type` when handled array option first, it isn't necessary to do again.
* `sql_type` has been determined already when quoting defaultsRyuta Kamizono2015-01-041-4/+2
| | | | No need to call `type_to_sql` again.
* Stop passing the column to the connection adapter when quoting defaultsSean Griffin2015-01-011-2/+2
| | | | | The column is no longer used for anything besides type casting, which is what we're trying to remove from the column entirely.
* Add bigint primary key support for MySQL.Ryuta Kamizono2014-12-281-0/+1
| | | | | | | Example: create_table :foos, id: :bigint do |t| end
* Support for any type primary key.Ryuta Kamizono2014-12-281-1/+5
|
* Merge pull request #17799 from kamipo/refactor_add_column_optionsRafael Mendonça França2014-11-281-2/+2
|\ | | | | Refactor `add_column_options!`, to move the quoting of default value for :uuid in `quote_value`.
| * Rename to `quote_default_expression` from `quote_value`Ryuta Kamizono2014-11-281-2/+2
| |
* | Refactor `SchemaCreation#visit_AddColumn`Ryuta Kamizono2014-11-271-3/+1
|/
* Add and Remove string/strip requireArthur Neves2014-09-021-0/+2
| | | | | | | Method .strip_heredoc is defined in active_support/core_ext/string/strip.rb so we need to require it. [fixes #16677]
* Always pass a column with a type object to quoteSean Griffin2014-06-281-0/+5
| | | | | | | | 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.
* fk: review corrections: indent, visibility, syntax, wording.Yves Senn2014-06-261-18/+18
|
* fk: use random digest namesYves Senn2014-06-261-1/+1
| | | | | | 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: raise for invalid :on_update / :on_delete valuesYves Senn2014-06-261-3/+8
|
* fk: support for on_updateYves Senn2014-06-261-2/+3
|
* fk: rename `dependent` to `on_delete`Yves Senn2014-06-261-6/+5
|
* fk: support dependent option (:delete, :nullify and :restrict).Yves Senn2014-06-261-1/+12
|
* fk: generalize using `AlterTable` and `SchemaCreation`.Yves Senn2014-06-261-0/+14
|
* fix bug on non empty defaults for pg array columnsLuke Steensen2014-03-301-1/+7
| | | | fixes #10613
* No need to call to_symRafael Mendonça França2014-03-301-2/+2
| | | | It is already called inside type_to_sql method.
* support creating temporary tables from queriesCody Cutrer2013-12-141-3/+4
| | | | | also override drop_table in AbstractMySQLAdapter to properly drop temporary tables without committing the transaction
* Move `SchemaCreation` to its own file instead of `AbstractAdapter`.Vipul A M2013-11-121-0/+83