aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate `active_support/core_ext/hash/compact`yuuji.yaginuma2018-03-021-2/+0
| | | | | Ruby 2.4+ provides `Hash#compact` and `Hash#compact!` natively, so `active_support/core_ext/hash/compact` is no longer necessary.
* Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-221-19/+18
| | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
* Remove deprecated `#migration_keys`Ryuta Kamizono2017-08-221-6/+0
|
* Require "active_support/core_ext/hash/compact" for `compact!`Ryuta Kamizono2017-08-211-0/+2
|
* Don't expose `prepare_column_options`Ryuta Kamizono2017-08-211-32/+13
| | | | | This is only used for the internal `column_spec` and `column_spec_for_primary_key`.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Merge pull request #27389 from kamipo/fix_mysql_pk_dumping_correctlyJeremy Daer2017-02-061-0/+6
|\ | | | | | | | | | | | | | | | | Restore the behaviour of the compatibility layer for integer-like PKs * kamipo/fix_mysql_pk_dumping_correctly: Restore custom primary key tests lost at #26266 Restore the behaviour of the compatibility layer for integer-like PKs Correctly dump integer-like primary key with default nil
| * Correctly dump integer-like primary key with default nilRyuta Kamizono2017-02-041-0/+6
| | | | | | | | | | | | | | The PR #27384 changed integer-like primary key to be autoincrement unless an explicit default. This means that integer-like primary key is restored as autoincrement unless dumping the default nil explicitly. We should dump integer-like primary key with default nil correctly.
* | Deprecate `ColumnDumper#migration_keys`Ryuta Kamizono2017-02-071-2/+3
|/ | | | | | `ColumnDumper#migration_keys` was extracted to customize keys for standardized column arguments widths. But the feature was removed in df84e98. The internal method is no longer used for that.
* Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-011-1/+9
| | | | | | | | | | | | | | | | | | | MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
* Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-051-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Extract `format_colspec` to format column specRyuta Kamizono2016-10-111-3/+1
|
* `name` is not a column optionRyuta Kamizono2016-10-101-2/+1
| | | | `migration_keys` includes `name` but `name` is not a column option.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-33/+33
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Database comments: Treat blank comments as no comment. Don't dump blank ↵Jeremy Daer2016-04-191-1/+1
| | | | comments.
* Merge pull request #23622 from kamipo/primary_key_should_be_not_nullJeremy Daer2016-04-181-1/+1
|\ | | | | | | Primary key should be `NOT NULL`
| * Primary key should be `NOT NULL`Ryuta Kamizono2016-03-121-1/+1
| | | | | | | | | | | | | | Follow up to #18228. In MySQL and PostgreSQL, primary key is to be `NOT NULL` implicitly. But in SQLite it must be specified `NOT NULL` explicitly.
* | Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-1/+3
|/ | | | | | | | | | | | | 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
* Merge pull request #24054 from kamipo/extract_default_primary_keyRafael França2016-03-111-1/+5
|\ | | | | Extract `default_primary_key?` to refactor `column_spec_for_primary_key`
| * Extract `default_primary_key?` to refactor `column_spec_for_primary_key`Ryuta Kamizono2016-03-111-1/+5
| |
* | Dump `bigint` instead of `integer` with `limit: 8` for schema dumperRyuta Kamizono2016-03-111-2/+6
|/ | | | | | | | | | | | | | | | | | Before: ```ruby create_table "big_numbers", force: :cascade do |t| t.integer "bigint_column", limit: 8 end ``` After: ```ruby create_table "big_numbers", force: :cascade do |t| t.bigint "bigint_column" end ```
* Exclude `:name` and `:type` from `prepare_column_options`Ryuta Kamizono2016-02-291-6/+6
| | | | Actually `:name` and `:type` are not column options.
* `schema_type` returns symbol rather than stringRyuta Kamizono2016-02-081-3/+3
| | | | | | | | | A return value of `schema_type` is used by: 1. primary key type: using as `symbol.inspect` 2. normal column type: using as `symbol.to_s` It is better to return symbol.
* Add expression support on the schema defaultRyuta Kamizono2016-01-131-1/+7
| | | | | | | | Example: create_table :posts do |t| t.datetime :published_at, default: -> { 'NOW()' } end
* Merge pull request #20815 from ↵Matthew Draper2015-12-181-2/+2
|\ | | | | | | | | | | byroot/do-not-include-column-limit-if-it-is-default Do not include column limit in schema.rb if it matches the default
| * Do not include column limit in schema.rb if it matches the defaultJean Boussier2015-07-081-2/+2
| | | | | | | | | | | | | | | | When working on engines that supports multiple databases, it's very annoying to have a different schema.rb output based on which database you use. MySQL being the primary offender. This patch should reduce the disparities a bit.
* | Move the methods for schema dumping into `{mysql,postgresql}/schema_dumper.rb`Ryuta Kamizono2015-10-131-1/+1
| | | | | | | | | | Current master branch includes many schema dumping improvements. It extract these features to the appropriate files.
* | Fix minor docs [ci skip] amitkumarsuroliya2015-09-281-1/+1
|/
* Divide methods for handling column options separatelyRyuta Kamizono2015-05-181-4/+24
|
* Move the collation handling code from the MySQL adapter to common classesRyuta Kamizono2015-05-041-1/+9
| | | | | Some databases like MySQL allow defining collation charset for specific columns.
* Correctly dump `serial` and `bigserial`Ryuta Kamizono2015-03-041-1/+5
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-1/+1
|
* The datetime precision with zero should be dumpedRyuta Kamizono2015-02-111-1/+1
| | | | | `precision: 0` was not dumped by f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7. However, `precision: 0` is valid value for PostgreSQL timestamps.
* Refactor microsecond precision to be database agnosticSean Griffin2015-02-101-1/+1
| | | | | | | | | | The various databases don't actually need significantly different handling for this behavior, and they can achieve it without knowing about the type of the object. The old implementation was returning a string, which will cause problems such as breaking TZ aware attributes, and making it impossible for the adapters to supply their logic for time objects.
* Remove most type related predicates from `Column`Sean Griffin2015-01-301-2/+3
| | | | | | Remaining are `limit`, `precision`, `scale`, and `type` (the symbol version). These will remain on the column, since they mirror the options to the `column` method in the schema definition DSL
* Improve a dump of the primary key support.Ryuta Kamizono2014-12-291-0/+6
| | | | If it is not a default primary key, correctly dump the type and options.
* no need to pass native_database_types aroundYves Senn2014-12-021-4/+4
|
* Remove redundant `to_s` in interpolationclaudiob2014-10-301-1/+1
|
* Include default column limits in schema.rbJeremy Kemper2014-09-101-4/+8
| | | | | | Allows :limit defaults to be changed without pulling the rug out from under old migrations that omitted :limit because it matched the default at the time.
* Don't type cast the default on the columnSean Griffin2014-06-171-1/+11
| | | | | | | If we want to have type decorators mess with the attribute, but not the column, we need to stop type casting on the column. Where possible, we changed the tests to test the value of `column_defaults`, which is public API. `Column#default` is not.
* Remove unused requireSean Griffin2014-06-111-2/+0
| | | | We're not longer using `ipaddr` in schema dumper
* refactor, introduce `Type#type_cast_for_schema` to cast for schema.rbYves Senn2014-05-301-26/+1
| | | | | | | This removes the case statement in `SchemaDumper` and gives every `Type` the possibility to control the SchemaDumper default value output. /cc @sgrif
* Remove special case in schema dumper for decimal without scaleSean Griffin2014-05-231-9/+2
|
* The sql_type method called here is fromRafael Mendonça França2013-03-251-1/+1
| | | | | | | ActiveRecord::ConnectionAdapters::Column See https://github.com/rails/rails/blob/28b8ca766e3e7c6c43d3ae900c99f8377153c62/activerecord/lib/active_record/connection_adapters/column.rb#L16
* Fix default output for postgres network address typesErik Peterson2013-02-261-0/+11
|
* Typo fixCarson McDonald2013-02-251-1/+1
|