aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/schema_dumper_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Dump `bigint` instead of `integer` with `limit: 8` for schema dumperRyuta Kamizono2016-03-111-6/+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 ```
* Revert "Dump indexes in `create_table` instead of `add_index`"Sean Griffin2016-02-051-10/+10
| | | | | | | | | | This reverts commit 99801c6a7b69eb4b006a55de17ada78f3a0fa4c1. Ultimately it doesn't matter whether `add_index` or `t.index` are used in the schema dumper in any meaningful way. There are gems out there which hook into the old behavior for things like indexing materialized views. Since the reverted commit doesn't seem to add much benefit, there's no reason for us to break these gems.
* Shorten ActiveRecord::InternalMetadata.table_name to ar_internal_metadataYasuo Honda2016-02-011-4/+4
| | | | to support Oracle database which only supports 30 byte identifier length
* Merge pull request #22967 from schneems/schneems/generic-metadataSean Griffin2016-01-081-0/+4
|\ | | | | Prevent destructive action on production database
| * Fixing tests and re-locating error checking.schneems2016-01-081-4/+4
| |
| * Prevent destructive action on production databaseschneems2016-01-071-0/+4
| | | | | | | | | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* | Merge pull request #20815 from ↵Matthew Draper2015-12-181-1/+1
|\ \ | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Remove legacy mysql adapterAbdelkader Boudih2015-12-171-4/+4
| |/ |/|
* | Internal test migrations use the private 'Current' versionMatthew Draper2015-12-151-2/+2
| | | | | | | | | | | | | | | | Apart from specific versioning support, our tests should focus on the behaviour of whatever version they're accompanying, regardless of when they were written. Application code should *not* do this.
* | Merge pull request #22271 from ↵Yves Senn2015-11-171-0/+32
|\ \ | | | | | | | | | | | | | | | timbreitkreutz/twb-9015-schema-dumper-test-for-prefix-and-ignore Test case for Issue #9015 - ignore_table and table_prefix at same time
| * | TWB Test case for Issue #9015 - ignore_table and table_prefix at same timeTim Breitkreutz2015-11-131-0/+32
|/ /
* / Fix to correctly schema dump the `tinyblob`Ryuta Kamizono2015-10-151-1/+1
|/ | | | | | Currently `tinyblob` is dumped to `t.binary "tiny_blob", limit: 255`. But `t.binary ... limit: 255` is generating SQL to `varchar(255)`. It is incorrect. This commit fixes this problem.
* Display decimal defaults as strings to keep precisionJohn Gesimondo2015-06-231-2/+2
|
* Correctly handle array columns with defaults in the schema dumperSean Griffin2015-06-111-0/+5
| | | | | | | | | If the subtype provides custom schema dumping behavior, we need to defer to it. We purposely choose not to handle any values other than an array (which technically should only ever be `nil`, but I'd rather code defensively here). Fixes #20515.
* Dump indexes in `create_table` instead of `add_index`Ryuta Kamizono2015-05-031-10/+10
| | | | | If the adapter supports indexes in create table, generated SQL is slightly more efficient.
* Fix (intermittent?) test failureMatthew Draper2015-04-131-1/+1
| | | | | | We don't actually need to enumerate the possible types here any more; that dates back to before e105e599e706780905d4c348394da989de3b200f, when they were symbols, and indistinguishable from other options.
* Delegate limit to subtypewallerjake2015-03-211-0/+5
| | | | | | | | | | As described here https://github.com/rails/rails/issues/19420. When using the Postgres BigInt[] field type the big int value was not being translated into schema.rb. This caused the field to become just a regular integer field when building off of schema.rb. This fix will address this by delegating the limit from the subtype to the Array type. https://github.com/rails/rails/issues/19420
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Fix mysql's schema.rb dumper so it does not include limit on emulated ↵Court3nay2015-02-241-0/+5
| | | | boolean tinyint(1) fields
* Add schema dumping tests for datetime and time precisionRyuta Kamizono2015-02-201-7/+0
|
* Prefer `drop_table if_exists: true` over raw SQLRyuta Kamizono2015-02-181-1/+1
| | | | | Lowercase raw SQL has been replaced by 07b659c already. This commit replaces everything else of raw SQL.
* Remove debug codeCarlos Antonio da Silva2015-02-081-5/+0
| | | | Added by 101c19f55f5f1d86d35574b805278f11e9a1a48e.
* Allow a symbol to be passed to `attribute`, in place of a type objectSean Griffin2015-02-061-0/+5
| | | | | | | | | | | | | | | | | | The same is not true of `define_attribute`, which is meant to be the low level no-magic API that sits underneath. The differences between the two APIs are: - `attribute` - Lazy (the attribute will be defined after the schema has loaded) - Allows either a type object or a symbol - `define_attribute` - Runs immediately (might get trampled by schema loading) - Requires a type object This was the last blocker in terms of public interface requirements originally discussed for this feature back in May. All the implementation blockers have been cleared, so this feature is probably ready for release (pending one more look-over by me).
* Fix `test_types_line_up` when column type missingRyuta Kamizono2015-01-301-2/+2
| | | | | | | a column type `xml` is missing in regexp pattarn. However, `assert_equal 1, lengths.uniq.length` is success when `lengths` are all `nil` because a column type is missing. a test will be failed by using `compact` when a column type is missing.