aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/schema_dumper_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert schema dumper to use strings rather than integerseileencodes2019-06-201-0/+1
| | | | | | | | | | | I think we should change this, but not in 6-0-stable since that's already in RC and I was trying to only make changes that won't require any app changes. This reverts a portion of https://github.com/rails/rails/pull/36439 that made all schema migration version numbers get dumped as an integer. While it doesn't _really_ matter it did change behavior. We should bring this back in 6.1 with a deprecation.
* Allow changing text and blob size without giving the `limit` optionRyuta Kamizono2019-01-291-9/+15
| | | | | | | | | | | | | | In MySQL, the text column size is 65,535 bytes by default (1 GiB in PostgreSQL). It is sometimes too short when people want to use a text column, so they sometimes change the text size to mediumtext (16 MiB) or longtext (4 GiB) by giving the `limit` option. Unlike MySQL, PostgreSQL doesn't allow the `limit` option for a text column (raises ERROR: type modifier is not allowed for type "text"). So `limit: 4294967295` (longtext) couldn't be used in Action Text. I've allowed changing text and blob size without giving the `limit` option, it prevents that migration failure on PostgreSQL.
* Support expression indexes for MySQLRyuta Kamizono2018-10-251-2/+5
| | | | | | | MySQL 8.0.13 and higher supports functional key parts that index expression values rather than column or column prefix values. https://dev.mysql.com/doc/refman/8.0/en/create-index.html
* SQLite3 adapter supports expression indexesgkemmey2018-09-131-5/+14
|
* Stub with Minitest instead of Mochautilum2018-07-151-17/+21
| | | | Step 4 in #33162
* Bump minimum SQLite version to 3.8Yasuo Honda2018-05-211-19/+1
| | | | | | | | | | | | | | These OS versions have SQLite 3.8 or higher by default. - macOS 10.10 (Yosemite) or higher - Ubuntu 14.04 LTS or higher Raising the minimum version of SQLite 3.8 introduces these changes: - All of bundled adapters support `supports_multi_insert?` - SQLite 3.8 always satisifies `supports_foreign_keys_in_create?` and `supports_partial_index?` - sqlite adapter can support `alter_table` method for foreign key referenced tables by #32865 - Deprecated `supports_multi_insert?` method
* Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-031-1/+1
| | | | | | 73e7aab behaved as expected on codeship, failing the build with exactly these RuboCop violations. Hopefully `rubocop -a` will have been enough to get a passing build!
* Fix multiline expression indexes for postgresql (#31621)fatkodima2018-03-161-1/+1
|
* Refactor `length`, `order`, and `opclass` index options dumpingRyuta Kamizono2017-12-031-3/+21
|
* Third party adapters doesn't support index orders yetRyuta Kamizono2017-10-261-2/+2
|
* Merge pull request #30970 from rohitpaulk/fix-sqlite-3-index-order-dumpRafael França2017-10-251-1/+1
|\ | | | | Save index order :desc to schema.rb (sqlite). Fixes #30902
| * Save index order :desc to schema.rb (sqlite). Fixes #30902Paul Kuruvilla2017-10-241-1/+1
| | | | | | | | | | Although the sqlite adapter supports index sort orders, they weren't being written to db/schema.rb.
* | `supports_extensions?` return always true since PostgreSQL 9.1Yasuo Honda2017-10-241-25/+23
|/ | | | | | | | since the minimum version of PostgreSQL currently Rails supports is 9.1, there is no need to handle if `supports_extensions?` Refer https://www.postgresql.org/docs/9.1/static/sql-createextension.html "CREATE EXTENSION"
* Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-271-3/+8
|
* Prefer to place a table options before `force: :cascade` (#28005)Ryuta Kamizono2017-08-271-1/+1
| | | | | | I was added a table options after `force: :cascade` in #17569 for not touching existing tests (reducing diff). But `force: :cascade` is not an important information. So I prefer to place a table options before `force: :cascade`.
* Allow `table_name_prefix` and `table_name_suffix` have `$`Yasuo Honda2017-08-041-0/+25
| | | | | | | | | | | | | | | | | | | MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign. * MySQL 5.7 https://dev.mysql.com/doc/refman/5.7/en/identifiers.html > Permitted characters in unquoted identifiers: > ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) * PostgreSQL 9.6 https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard. Address #30044 [Yasuo Honda & Ryuta Kamizono]
* Merge pull request #29768 from janpieper/sort-enabled-extensions-in-dumpEileen M. Uchitelle2017-07-221-0/+14
|\ | | | | Sort enabled adapter extensions in schema dump
| * Sort enabled adapter extensions in schema dumpJan Pieper2017-07-121-0/+14
| | | | | | | | | | | | | | | | The list of enabled adapter extensions in the schema dump isn't sorted by default, so it may happen that the sorting changes over time. If you're using a VCS, a change to the sorting results in a diff without any real change. Sorting the list should solve this problem.
* | 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
|
* Fix `dump_schema_information` with empty versionsRyuta Kamizono2017-06-151-0/+6
| | | | Fixes #29460.
* Avoid overwriting the methods of `AttributeMethods::PrimaryKey`Ryuta Kamizono2017-06-071-1/+1
| | | | | | | | | Currently the methods of `AttributeMethods::PrimaryKey` are overwritten by `define_attribute_methods`. It will be broken if a table that customized primary key has non primary key id column. It should not be overwritten if a table has any primary key. Fixes #29350.
* Simplify `assert_no_match %r{colname.*limit:}` regexRyuta Kamizono2017-06-011-14/+4
| | | | | In `test_schema_dump_includes_limit_constraint_for_integer_columns`, unified `assert_match` and `assert_no_match` to simple regex.
* Support Descending Indexes for MySQLRyuta Kamizono2017-04-161-1/+5
| | | | | | | MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored. See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
* Merge pull request #25296 from kamipo/use_inspect_for_type_cast_for_schemaRafael França2017-02-281-7/+8
|\ | | | | Use `inspect` in `type_cast_for_schema` for date/time and decimal values
| * Use `inspect` in `type_cast_for_schema` for date/time and decimal valuesRyuta Kamizono2016-12-111-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently dumping defaults on schema is inconsistent. Before: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: '2014-06-05' t.datetime "datetime_with_default", default: '2014-06-05 07:17:04' t.time "time_with_default", default: '2000-01-01 07:17:04' t.decimal "decimal_with_default", default: 1234567890 end ``` After: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: "2014-06-05" t.datetime "datetime_with_default", default: "2014-06-05 07:17:04" t.time "time_with_default", default: "2000-01-01 07:17:04" t.decimal "decimal_with_default", default: "1234567890" end ```
* | Omit redundant `using: :btree` for schema dumpingRyuta Kamizono2017-02-131-14/+10
| |
* | Schema dumping support for PostgreSQL oid typeRyuta Kamizono2017-02-121-0/+5
| | | | | | | | Closes #27980
* | Schema dumping support for PostgreSQL interval typeRyuta Kamizono2017-02-121-4/+10
| | | | | | | | Closes #27979
* | `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-071-1/+1
| | | | | | | | | | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* | Should work foreign key in test schema without `if supports_foreign_keys?` ↵Ryuta Kamizono2017-01-171-1/+1
| | | | | | | | | | | | | | | | | | statement If an adapter does not support foreign key feature, should be noop. https://github.com/rails/rails/blob/v5.0.0.rc1/activerecord/test/cases/migration/foreign_key_test.rb#L288-L294 https://github.com/rails/rails/blob/v5.0.0.rc1/activerecord/test/cases/migration/references_foreign_key_test.rb#L208-L214
* | Consolidate duplicated elsif branchRyuta Kamizono2016-12-191-6/+1
|/
* 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
|
* Fix table comment dumpingRyuta Kamizono2016-10-111-0/+1
| | | | | | | | | | | | | Follow up to #26735. If `table_options` returns `{ comment: nil }`, `create_table` line is broken. Example: ```ruby create_table "accounts", force: :cascade, do |t| ```
* Dump index options to pretty formatRyuta Kamizono2016-10-101-2/+4
| | | | | | | | | | ```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
* Merge pull request #24571 from raimo/patch-1Sean Griffin2016-10-041-0/+14
|\ | | | | Print the proper ::Float::INFINITY value when used as a default value
| * Print the proper ::Float::INFINITY value when used as a default valueRaimo Tuisku2016-05-231-0/+14
| | | | | | | | Addresses https://github.com/rails/rails/issues/22396
* | Remove the SchemaDumper options and change the default behaviorRafael Mendonça França2016-08-221-93/+12
| | | | | | | | | | Now the schema dumper by default doesn't align the types and arguments in the ruby format anymore.
* | Option not to line up column types and attributes in schema.rbTim Petricola2016-08-171-0/+78
| |
* | Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-2/+2
| |
* | applies new string literal convention in activerecord/testXavier Noria2016-08-061-10/+10
| | | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | Do not include default column limit in schema.rbRyuta Kamizono2016-05-311-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up of #20815. ```ruby class CreatePeople < ActiveRecord::Migration[5.0] def change create_table :people do |t| t.integer :int t.bigint :bint t.text :txt t.binary :bin end end end ``` Result. In postgresql and sqlite3 adapters: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ``` In mysql2 adapter: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt", limit: 65535 t.binary "bin", limit: 65535 end end ``` After this patch: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ```
* | Remove magic comment in generated `schema.rb`Ryuta Kamizono2016-05-121-4/+0
|/ | | | | Rails 5.0 has been dropped Ruby 1.9 support. I think no need magic comment anymore.
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-241-1/+6
| | | | | | | | | | | | | | | | Example: create_table :users do |t| t.string :name t.index 'lower(name) varchar_pattern_ops' end Fixes #19090. Fixes #21765. Fixes #21819. Fixes #24359. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a ↵Vipul A M2016-04-231-0/+18
| | | | | | | | | 78 changed INSERT INTO versions to run in 1 single query. This breaks for sqlite versions < 3.7.11, which is especially the case on Ubuntu 12.04 LTS, that has SQLite version 3.7.9 as default. So we check for support for multi insert, before performing single query inserts, else fallback to older version of running multiple queries. [Vipul A M & Yasuo Honda]
* Dump indexes in `create_table` for generates SQL in one queryRyuta Kamizono2016-04-201-10/+10
| | | | | If the adapter supports indexes in create table, it generates SQL in one query.
* `foreign_key` respects `table_name_prefix` and `table_name_suffix`Ryuta Kamizono2016-04-191-2/+2
|