From 122e8dc1e9fab32f56e13902fb2a2c509716acfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Mar=C4=8Deti=C4=87?= Date: Mon, 27 May 2013 03:31:13 +0200 Subject: Correct the assertion that join table columns have no options, mind context. --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 550f8fdc3c..1ad8db12eb 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -377,8 +377,8 @@ create_join_table :products, :categories, table_name: :categorization will create a `categorization` table. -By default, `create_join_table` will create two columns with no options, but -you can specify these options using the `:column_options` option. For example, +For the two table columns, you can override the default `:null` option, or add +others, by specifying the `:column_options` option. For example, ```ruby create_join_table :products, :categories, column_options: {null: true} -- cgit v1.2.3 From 70b302b189dbe9f90e3b081fa540c909a43ba8d0 Mon Sep 17 00:00:00 2001 From: Sunny Ripert Date: Tue, 28 May 2013 14:36:18 +0200 Subject: Remove double spaces in code examples --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 1ad8db12eb..ae0726c559 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -877,7 +877,7 @@ end # app/models/product.rb class Product < ActiveRecord::Base - validates :flag, inclusion: { in: [true, false] } + validates :flag, inclusion: { in: [true, false] } validates :fuzz, presence: true end ``` -- cgit v1.2.3 From 53607be559ec60e3b5bd915f8533550648f7ef8a Mon Sep 17 00:00:00 2001 From: Sunny Ripert Date: Tue, 28 May 2013 14:37:04 +0200 Subject: Remove double spaces in guides --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index ae0726c559..194ae276ec 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -448,7 +448,7 @@ definitions: * `create_table` * `create_join_table` * `drop_table` (must supply a block) -* `drop_join_table` (must supply a block) +* `drop_join_table` (must supply a block) * `remove_timestamps` * `rename_column` * `rename_index` -- cgit v1.2.3 From 7663149f72b5dba15a8e850e4072a016341e541c Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 14 Jun 2013 00:58:11 +0530 Subject: copy edits [ci skip] --- guides/source/migrations.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 194ae276ec..eb0cfd9451 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -366,26 +366,24 @@ create_join_table :products, :categories which creates a `categories_products` table with two columns called `category_id` and `product_id`. These columns have the option `:null` set to -`false` by default. - -You can pass the option `:table_name` with you want to customize the table -name. For example, +`false` by default. This can be overridden by specifying the `:column_options` +option. ```ruby -create_join_table :products, :categories, table_name: :categorization +create_join_table :products, :categories, column_options: {null: true} ``` -will create a `categorization` table. +will create the `product_id` and `category_id` with the `:null` option as +`true`. -For the two table columns, you can override the default `:null` option, or add -others, by specifying the `:column_options` option. For example, +You can pass the option `:table_name` with you want to customize the table +name. For example, ```ruby -create_join_table :products, :categories, column_options: {null: true} +create_join_table :products, :categories, table_name: :categorization ``` -will create the `product_id` and `category_id` with the `:null` option as -`true`. +will create a `categorization` table. `create_join_table` also accepts a block, which you can use to add indices (which are not created by default) or additional columns: -- cgit v1.2.3 From 56ddb8917d62681c7e056f5386305d32c2484ba5 Mon Sep 17 00:00:00 2001 From: Satoshi Ebisawa Date: Fri, 21 Jun 2013 17:27:55 +0900 Subject: Fix documents for create_join_table --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index eb0cfd9451..508e52a77c 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -390,8 +390,8 @@ will create a `categorization` table. ```ruby create_join_table :products, :categories do |t| - t.index :products - t.index :categories + t.index :product_id + t.index :category_id end ``` -- cgit v1.2.3 From a0bdf2fff57c03f9c0d1553a6c9e44d52937dc77 Mon Sep 17 00:00:00 2001 From: dkaplan88 Date: Sat, 29 Jun 2013 17:11:43 -0500 Subject: Typo in Active Record Migrations Guide [ci skip] --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 508e52a77c..035f9499de 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -314,7 +314,7 @@ will produce a migration that looks like this class AddDetailsToProducts < ActiveRecord::Migration def change add_column :products, :price, precision: 5, scale: 2 - add_reference :products, :user, polymorphic: true, index: true + add_reference :products, :supplier, polymorphic: true, index: true end end ``` -- cgit v1.2.3 From f6b75ff3779913f07c9c79213873fd80809924bf Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Mon, 8 Jul 2013 15:53:53 +0900 Subject: Update 'Active Record Migrations' guide [ci skip] Delete an unneeded line. --- guides/source/migrations.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 035f9499de..f191b110cd 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -841,7 +841,6 @@ class AddFlagToProduct < ActiveRecord::Migration reversible do |dir| dir.up { Product.update_all flag: false } end - Product.update_all flag: false end end ``` -- cgit v1.2.3 From e863410b5838ee17de077f301b2d6aea9668bb23 Mon Sep 17 00:00:00 2001 From: Daniel Dawson Date: Mon, 8 Jul 2013 22:56:09 +0100 Subject: Fix a grammatical error/typo in Active Record Migrations guide. [ci skip] --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index f191b110cd..e6d1e71f5e 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -376,7 +376,7 @@ create_join_table :products, :categories, column_options: {null: true} will create the `product_id` and `category_id` with the `:null` option as `true`. -You can pass the option `:table_name` with you want to customize the table +You can pass the option `:table_name` when you want to customize the table name. For example, ```ruby -- cgit v1.2.3 From 3baee0982d25e64cab2eeb046369f0fcf9ee2436 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 5 Aug 2013 16:36:50 +0200 Subject: migrations guide: fix and edits [ci skip] --- guides/source/migrations.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index e6d1e71f5e..6100fc89c8 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -829,8 +829,7 @@ which contains a `Product` model: Bob goes on vacation. Alice creates a migration for the `products` table which adds a new column and -initializes it. She also adds a validation to the `Product` model for the new -column. +initializes it: ```ruby # db/migrate/20100513121110_add_flag_to_product.rb @@ -845,6 +844,8 @@ class AddFlagToProduct < ActiveRecord::Migration end ``` +She also adds a validation to the `Product` model for the new column: + ```ruby # app/models/product.rb @@ -853,9 +854,8 @@ class Product < ActiveRecord::Base end ``` -Alice adds a second migration which adds and initializes another column to the -`products` table and also adds a validation to the `Product` model for the new -column. +Alice adds a second migration which adds another column to the `products` +table and initializes it: ```ruby # db/migrate/20100515121110_add_fuzz_to_product.rb @@ -870,6 +870,8 @@ class AddFuzzToProduct < ActiveRecord::Migration end ``` +She also adds a validation to the `Product` model for the new column: + ```ruby # app/models/product.rb @@ -903,7 +905,7 @@ A fix for this is to create a local model within the migration. This keeps Rails from running the validations, so that the migrations run to completion. When using a local model, it's a good idea to call -`Product.reset_column_information` to refresh the `ActiveRecord` cache for the +`Product.reset_column_information` to refresh the Active Record cache for the `Product` model prior to updating data in the database. If Alice had done this instead, there would have been no problem: @@ -956,7 +958,7 @@ other product attributes. These migrations run just fine, but when Bob comes back from his vacation and calls `rake db:migrate` to run all the outstanding migrations, he gets a subtle bug: The descriptions have defaults, and the `fuzz` column is present, -but `fuzz` is nil on all products. +but `fuzz` is `nil` on all products. The solution is again to use `Product.reset_column_information` before referencing the Product model in a migration, ensuring the Active Record's -- cgit v1.2.3 From d4863f30de023d0f6817afcddc114889493e6d3c Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Thu, 29 Aug 2013 11:12:57 -0500 Subject: Note functional equivalence in reset task --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 6100fc89c8..55bb89bd71 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -694,8 +694,8 @@ version to migrate to. ### Resetting the Database -The `rake db:reset` task will drop the database, recreate it and load the -current schema into it. +The `rake db:reset` task will drop the database and set it up again. This is +functionally eqivalent to `rake db:drop db:setup` NOTE: This is not the same as running all the migrations. It will only use the contents of the current schema.rb file. If a migration can't be rolled back, -- cgit v1.2.3 From 5f08154230f69a8aee88d72e09fe088bf728f506 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Thu, 29 Aug 2013 11:18:07 -0500 Subject: Add documentation for rake db:setup task --- guides/source/migrations.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 55bb89bd71..d154dae752 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -692,6 +692,11 @@ Neither of these Rake tasks do anything you could not do with `db:migrate`. They are simply more convenient, since you do not need to explicitly specify the version to migrate to. +### Setup the Database + +The `rake db:setup` task will create the database, load the schema and initialize +it with seed data. + ### Resetting the Database The `rake db:reset` task will drop the database and set it up again. This is -- cgit v1.2.3 From 3bcecf8258d6b63ded2714672f92ad767423e41f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 30 Aug 2013 01:10:30 -0300 Subject: Fix typos [ci skip] --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index d154dae752..414ce46a4e 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -695,12 +695,12 @@ version to migrate to. ### Setup the Database The `rake db:setup` task will create the database, load the schema and initialize -it with seed data. +it with the seed data. ### Resetting the Database The `rake db:reset` task will drop the database and set it up again. This is -functionally eqivalent to `rake db:drop db:setup` +functionally equivalent to `rake db:drop db:setup`. NOTE: This is not the same as running all the migrations. It will only use the contents of the current schema.rb file. If a migration can't be rolled back, -- cgit v1.2.3 From febe40a15979e38fe67a423d6352f832b9253776 Mon Sep 17 00:00:00 2001 From: mogetutu Date: Thu, 12 Sep 2013 12:50:11 +0300 Subject: Added quotes when defining the precision for the `decimal` fields before: ```bash $ rails generate migration AddDetailsToProducts price:decimal{5,2} supplier:references{polymorphic} ``` after: ```bash $ rails generate migration AddDetailsToProducts 'price:decimal{5,2}' supplier:references{polymorphic} ``` --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 414ce46a4e..ab39b39a1c 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -305,7 +305,7 @@ braces. You can use the following modifiers: For instance, running ```bash -$ rails generate migration AddDetailsToProducts price:decimal{5,2} supplier:references{polymorphic} +$ rails generate migration AddDetailsToProducts 'price:decimal{5,2}' supplier:references{polymorphic} ``` will produce a migration that looks like this -- cgit v1.2.3 From 39a454d8a042bd2ced8dc659324fc51779a45ab9 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Tue, 17 Sep 2013 00:33:14 +0800 Subject: [ci skip] Improve readability of 4.3's NOTE in migration.md. --- guides/source/migrations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index ab39b39a1c..3c512e0390 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -703,9 +703,9 @@ The `rake db:reset` task will drop the database and set it up again. This is functionally equivalent to `rake db:drop db:setup`. NOTE: This is not the same as running all the migrations. It will only use the -contents of the current schema.rb file. If a migration can't be rolled back, -'rake db:reset' may not help you. To find out more about dumping the schema see -'[schema dumping and you](#schema-dumping-and-you).' +contents of the current `schema.rb` file. If a migration can't be rolled back, +`rake db:reset` may not help you. To find out more about dumping the schema see +[Schema Dumping and You](#schema-dumping-and-you) section. ### Running Specific Migrations -- cgit v1.2.3 From 8e41af93a39cacbc813e66d38b05ffc98d412209 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Sun, 22 Sep 2013 16:09:43 +0800 Subject: [ci skip] Add a type modifier in migrations.md. --- guides/source/migrations.md | 1 + 1 file changed, 1 insertion(+) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 3c512e0390..1c858069f3 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -301,6 +301,7 @@ braces. You can use the following modifiers: * `precision` Defines the precision for the `decimal` fields * `scale` Defines the scale for the `decimal` fields * `polymorphic` Adds a `type` column for `belongs_to` associations +* `null` Allows or disallows `NULL` values in the column. For instance, running -- cgit v1.2.3 From de1e502429b1287d8bc07cbfbe6638d24322b1e7 Mon Sep 17 00:00:00 2001 From: Ofer Nave Date: Tue, 24 Sep 2013 12:27:21 -0400 Subject: added column type to example in section 2.3 --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 1c858069f3..0f5379059e 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -314,7 +314,7 @@ will produce a migration that looks like this ```ruby class AddDetailsToProducts < ActiveRecord::Migration def change - add_column :products, :price, precision: 5, scale: 2 + add_column :products, :price, :decimal, precision: 5, scale: 2 add_reference :products, :supplier, polymorphic: true, index: true end end -- cgit v1.2.3 From b66110c0369f43ae11b580c80b9e18ebdcab1ac4 Mon Sep 17 00:00:00 2001 From: Francis Go Date: Sat, 28 Sep 2013 15:04:01 +1000 Subject: Migrations Guide: Add semicolon to sentences before code block [ci skip] --- guides/source/migrations.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 0f5379059e..5166e61ec5 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -184,7 +184,7 @@ class RemovePartNumberFromProducts < ActiveRecord::Migration end ``` -You are not limited to one magically generated column. For example +You are not limited to one magically generated column. For example: ```bash $ rails generate migration AddDetailsToProducts part_number:string price:decimal @@ -227,7 +227,7 @@ or remove from it as you see fit by editing the `db/migrate/YYYYMMDDHHMMSS_add_details_to_products.rb` file. Also, the generator accepts column type as `references`(also available as -`belongs_to`). For instance +`belongs_to`). For instance: ```bash $ rails generate migration AddUserRefToProducts user:references @@ -269,7 +269,7 @@ end The model and scaffold generators will create migrations appropriate for adding a new model. This migration will already contain instructions for creating the relevant table. If you tell Rails what columns you want, then statements for -adding these columns will also be created. For example, running +adding these columns will also be created. For example, running: ```bash $ rails generate model Product name:string description:text @@ -303,7 +303,7 @@ braces. You can use the following modifiers: * `polymorphic` Adds a `type` column for `belongs_to` associations * `null` Allows or disallows `NULL` values in the column. -For instance, running +For instance, running: ```bash $ rails generate migration AddDetailsToProducts 'price:decimal{5,2}' supplier:references{polymorphic} @@ -345,7 +345,7 @@ By default, `create_table` will create a primary key called `id`. You can change the name of the primary key with the `:primary_key` option (don't forget to update the corresponding model) or, if you don't want a primary key at all, you can pass the option `id: false`. If you need to pass database specific options -you can place an SQL fragment in the `:options` option. For example, +you can place an SQL fragment in the `:options` option. For example: ```ruby create_table :products, options: "ENGINE=BLACKHOLE" do |t| @@ -359,7 +359,7 @@ will append `ENGINE=BLACKHOLE` to the SQL statement used to create the table ### Creating a Join Table Migration method `create_join_table` creates a HABTM join table. A typical use -would be +would be: ```ruby create_join_table :products, :categories @@ -378,7 +378,7 @@ will create the `product_id` and `category_id` with the `:null` option as `true`. You can pass the option `:table_name` when you want to customize the table -name. For example, +name. For example: ```ruby create_join_table :products, :categories, table_name: :categorization @@ -400,7 +400,7 @@ end A close cousin of `create_table` is `change_table`, used for changing existing tables. It is used in a similar fashion to `create_table` but the object -yielded to the block knows more tricks. For example +yielded to the block knows more tricks. For example: ```ruby change_table :products do |t| @@ -464,7 +464,7 @@ or write the `up` and `down` methods instead of using the `change` method. Complex migrations may require processing that Active Record doesn't know how to reverse. You can use `reversible` to specify what to do when running a -migration what else to do when reverting it. For example, +migration what else to do when reverting it. For example: ```ruby class ExampleMigration < ActiveRecord::Migration @@ -648,7 +648,7 @@ will update your `db/schema.rb` file to match the structure of your database. If you specify a target version, Active Record will run the required migrations (change, up, down) until it has reached the specified version. The version is the numerical prefix on the migration's filename. For example, to migrate -to version 20080906120000 run +to version 20080906120000 run: ```bash $ rake db:migrate VERSION=20080906120000 @@ -665,7 +665,7 @@ down to, but not including, 20080906120000. A common task is to rollback the last migration. For example, if you made a mistake in it and wish to correct it. Rather than tracking down the version -number associated with the previous migration you can run +number associated with the previous migration you can run: ```bash $ rake db:rollback @@ -683,7 +683,7 @@ will revert the last 3 migrations. The `db:migrate:redo` task is a shortcut for doing a rollback and then migrating back up again. As with the `db:rollback` task, you can use the `STEP` parameter -if you need to go more than one version back, for example +if you need to go more than one version back, for example: ```bash $ rake db:migrate:redo STEP=3 @@ -713,7 +713,7 @@ contents of the current `schema.rb` file. If a migration can't be rolled back, If you need to run a specific migration up or down, the `db:migrate:up` and `db:migrate:down` tasks will do that. Just specify the appropriate version and the corresponding migration will have its `change`, `up` or `down` method -invoked, for example, +invoked, for example: ```bash $ rake db:migrate:up VERSION=20080906120000 @@ -755,7 +755,7 @@ Several methods are provided in migrations that allow you to control all this: | say | Takes a message argument and outputs it as is. A second boolean argument can be passed to specify whether to indent or not. | say_with_time | Outputs text along with how long it took to run its block. If the block returns an integer it assumes it is the number of rows affected. -For example, this migration +For example, this migration: ```ruby class CreateProducts < ActiveRecord::Migration -- cgit v1.2.3 From 98a5169c2ee6355a6e13df33b6219b04201d1c96 Mon Sep 17 00:00:00 2001 From: Francis Go Date: Sat, 28 Sep 2013 15:39:12 +1000 Subject: Migrations Guide: Fix line length [ci skip] --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 0f5379059e..83e7097020 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -1040,8 +1040,8 @@ this, then you should set the schema format to `:sql`. Instead of using Active Record's schema dumper, the database's structure will be dumped using a tool specific to the database (via the `db:structure:dump` Rake task) into `db/structure.sql`. For example, for PostgreSQL, the `pg_dump` -utility is used. For MySQL, this file will contain the output of `SHOW CREATE -TABLE` for the various tables. +utility is used. For MySQL, this file will contain the output of +`SHOW CREATE TABLE` for the various tables. Loading these schemas is simply a question of executing the SQL statements they contain. By definition, this will create a perfect copy of the database's -- cgit v1.2.3 From f387aa1bdd09866386dcdf829542e27e7c4d626d Mon Sep 17 00:00:00 2001 From: Jimmy Petersen Date: Mon, 11 Nov 2013 13:35:57 +0100 Subject: Fixed typo in migrations guide Product model name was pluralized in example in migrations guide. [ci skip] --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index b7283d16cc..71a177bca7 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -420,7 +420,7 @@ If the helpers provided by Active Record aren't enough you can use the `execute` method to execute arbitrary SQL: ```ruby -Products.connection.execute('UPDATE `products` SET `price`=`free` WHERE 1') +Product.connection.execute('UPDATE `products` SET `price`=`free` WHERE 1') ``` For more details and examples of individual methods, check the API documentation. -- cgit v1.2.3 From 9c9d4948e428a226a19aa92c17fa6ac5833c2fb8 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Tue, 12 Nov 2013 15:56:17 +0100 Subject: `remove_column` does not take a type argument. [ci skip]. Closes #12864 --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 71a177bca7..93c7314779 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -179,7 +179,7 @@ generates ```ruby class RemovePartNumberFromProducts < ActiveRecord::Migration def change - remove_column :products, :part_number, :string + remove_column :products, :part_number end end ``` -- cgit v1.2.3 From 49245f37f7fc60bea5862aae1c9f8e1f1475872d Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 13 Nov 2013 09:02:11 +0100 Subject: Revert "`remove_column` does not take a type argument. [ci skip]. Closes #12864" As of Rails 4.0 `remove_column` is no longer an alias for `remove_columns`. The type is actually valid and used when issuing a rollback (new `change` method). This reverts commit 9c9d4948e428a226a19aa92c17fa6ac5833c2fb8. --- guides/source/migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 93c7314779..71a177bca7 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -179,7 +179,7 @@ generates ```ruby class RemovePartNumberFromProducts < ActiveRecord::Migration def change - remove_column :products, :part_number + remove_column :products, :part_number, :string end end ``` -- cgit v1.2.3 From e2c17cfb2b57a8543976e478a63f62c880c224ad Mon Sep 17 00:00:00 2001 From: Taryn East Date: Wed, 18 Dec 2013 11:48:37 +1100 Subject: [ci skip] Describe precision + scale in migrations Telling somebody that "precision sets the precision" is not very helpful. Newbies want to know what precision is *for*, likewise with scale. So I've added a very brief description for each. --- guides/source/migrations.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index 71a177bca7..5d5c2724b1 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -297,10 +297,10 @@ You can append as many column name/type pairs as you want. You can also specify some options just after the field type between curly braces. You can use the following modifiers: -* `limit` Sets the maximum size of the `string/text/binary/integer` fields -* `precision` Defines the precision for the `decimal` fields -* `scale` Defines the scale for the `decimal` fields -* `polymorphic` Adds a `type` column for `belongs_to` associations +* `limit` Sets the maximum size of the `string/text/binary/integer` fields. +* `precision` Defines the precision for the `decimal` fields, representing the total number of digits in the number. +* `scale` Defines the scale for the `decimal` fields, representing the number of digits after the decimal point. +* `polymorphic` Adds a `type` column for `belongs_to` associations. * `null` Allows or disallows `NULL` values in the column. For instance, running: -- cgit v1.2.3