aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb48
1 files changed, 24 insertions, 24 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 86d6266af9..8790518d37 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -36,10 +36,10 @@ module ActiveRecord
# index_exists?(:suppliers, [:company_id, :company_type])
#
# # Check a unique index exists
- # index_exists?(:suppliers, :company_id, :unique => true)
+ # index_exists?(:suppliers, :company_id, unique: true)
#
# # Check an index with a custom name exists
- # index_exists?(:suppliers, :company_id, :name => "idx_company_id"
+ # index_exists?(:suppliers, :company_id, name: "idx_company_id"
def index_exists?(table_name, column_name, options = {})
column_names = Array(column_name)
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, :column => column_names)
@@ -89,14 +89,14 @@ module ActiveRecord
# # table.
#
# create_table(:suppliers) do |t|
- # t.column :name, :string, :limit => 60
+ # t.column :name, :string, limit: 60
# # Other fields here
# end
#
# === Block form, with shorthand
# # You can also use the column types as method calls, rather than calling the column method.
# create_table(:suppliers) do |t|
- # t.string :name, :limit => 60
+ # t.string :name, limit: 60
# # Other fields here
# end
#
@@ -104,7 +104,7 @@ module ActiveRecord
# # Creates a table called 'suppliers' with no columns.
# create_table(:suppliers)
# # Add a column to 'suppliers'.
- # add_column(:suppliers, :name, :string, {:limit => 60})
+ # add_column(:suppliers, :name, :string, {limit: 60})
#
# The +options+ hash can include the following keys:
# [<tt>:id</tt>]
@@ -127,15 +127,15 @@ module ActiveRecord
# Defaults to false.
#
# ====== Add a backend specific option to the generated SQL (MySQL)
- # create_table(:suppliers, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
+ # create_table(:suppliers, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
# generates:
# CREATE TABLE suppliers (
# id int(11) DEFAULT NULL auto_increment PRIMARY KEY
# ) ENGINE=InnoDB DEFAULT CHARSET=utf8
#
# ====== Rename the primary key column
- # create_table(:objects, :primary_key => 'guid') do |t|
- # t.column :name, :string, :limit => 80
+ # create_table(:objects, primary_key: 'guid') do |t|
+ # t.column :name, :string, limit: 80
# end
# generates:
# CREATE TABLE objects (
@@ -144,7 +144,7 @@ module ActiveRecord
# )
#
# ====== Do not add a primary key column
- # create_table(:categories_suppliers, :id => false) do |t|
+ # create_table(:categories_suppliers, id: false) do |t|
# t.column :category_id, :integer
# t.column :supplier_id, :integer
# end
@@ -193,7 +193,7 @@ module ActiveRecord
# Defaults to false.
#
# ====== Add a backend specific option to the generated SQL (MySQL)
- # create_join_table(:assemblies, :parts, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
+ # create_join_table(:assemblies, :parts, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
# generates:
# CREATE TABLE assemblies_parts (
# assembly_id int NOT NULL,
@@ -218,7 +218,7 @@ module ActiveRecord
#
# # change_table() yields a Table instance
# change_table(:suppliers) do |t|
- # t.column :name, :string, :limit => 60
+ # t.column :name, :string, limit: 60
# # Other column alterations here
# end
#
@@ -231,12 +231,12 @@ module ActiveRecord
#
# ====== Add a column
# change_table(:suppliers) do |t|
- # t.column :name, :string, :limit => 60
+ # t.column :name, :string, limit: 60
# end
#
# ====== Add 2 integer columns
# change_table(:suppliers) do |t|
- # t.integer :width, :height, :null => false, :default => 0
+ # t.integer :width, :height, null: false, default: 0
# end
#
# ====== Add created_at/updated_at columns
@@ -253,7 +253,7 @@ module ActiveRecord
#
# ====== Add a polymorphic foreign key column
# change_table(:suppliers) do |t|
- # t.belongs_to :company, :polymorphic => true
+ # t.belongs_to :company, polymorphic: true
# end
#
# Creates <tt>company_type(varchar)</tt> and <tt>company_id(integer)</tt> columns
@@ -318,7 +318,7 @@ module ActiveRecord
# Changes the column's definition according to the new options.
# See TableDefinition#column for details of the options you can use.
#
- # change_column(:suppliers, :name, :string, :limit => 80)
+ # change_column(:suppliers, :name, :string, limit: 80)
# change_column(:accounts, :description, :text)
def change_column(table_name, column_name, type, options = {})
raise NotImplementedError, "change_column is not implemented"
@@ -352,35 +352,35 @@ module ActiveRecord
# CREATE INDEX suppliers_name_index ON suppliers(name)
#
# ====== Creating a unique index
- # add_index(:accounts, [:branch_id, :party_id], :unique => true)
+ # add_index(:accounts, [:branch_id, :party_id], unique: true)
# generates
# CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id)
#
# ====== Creating a named index
- # add_index(:accounts, [:branch_id, :party_id], :unique => true, :name => 'by_branch_party')
+ # add_index(:accounts, [:branch_id, :party_id], unique: true, name: 'by_branch_party')
# generates
# CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id)
#
# ====== Creating an index with specific key length
- # add_index(:accounts, :name, :name => 'by_name', :length => 10)
+ # add_index(:accounts, :name, name: 'by_name', length: 10)
# generates
# CREATE INDEX by_name ON accounts(name(10))
#
- # add_index(:accounts, [:name, :surname], :name => 'by_name_surname', :length => {:name => 10, :surname => 15})
+ # add_index(:accounts, [:name, :surname], name: 'by_name_surname', length: {name: 10, surname: 15})
# generates
# CREATE INDEX by_name_surname ON accounts(name(10), surname(15))
#
# Note: SQLite doesn't support index length
#
# ====== Creating an index with a sort order (desc or asc, asc is the default)
- # add_index(:accounts, [:branch_id, :party_id, :surname], :order => {:branch_id => :desc, :party_id => :asc})
+ # add_index(:accounts, [:branch_id, :party_id, :surname], order: {branch_id: :desc, party_id: :asc})
# generates
# CREATE INDEX by_branch_desc_party ON accounts(branch_id DESC, party_id ASC, surname)
#
# Note: mysql doesn't yet support index order (it accepts the syntax but ignores it)
#
# ====== Creating a partial index
- # add_index(:accounts, [:branch_id, :party_id], :unique => true, :where => "active")
+ # add_index(:accounts, [:branch_id, :party_id], unique: true, where: "active")
# generates
# CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active
#
@@ -396,11 +396,11 @@ module ActiveRecord
# Remove the index_accounts_on_column in the accounts table.
# remove_index :accounts, :column
# Remove the index named index_accounts_on_branch_id in the accounts table.
- # remove_index :accounts, :column => :branch_id
+ # remove_index :accounts, column: :branch_id
# Remove the index named index_accounts_on_branch_id_and_party_id in the accounts table.
- # remove_index :accounts, :column => [:branch_id, :party_id]
+ # remove_index :accounts, column: [:branch_id, :party_id]
# Remove the index named by_branch_party in the accounts table.
- # remove_index :accounts, :name => :by_branch_party
+ # remove_index :accounts, name: :by_branch_party
def remove_index(table_name, options = {})
remove_index!(table_name, index_name_for_remove(table_name, options))
end