Migration of docs to 1.9 hash syntax
This commit is contained in:
parent
3b89052014
commit
9edd4e18c4
@ -72,7 +72,7 @@ class Preloader #:nodoc:
|
|||||||
# books.
|
# books.
|
||||||
# - a Hash which specifies multiple association names, as well as
|
# - a Hash which specifies multiple association names, as well as
|
||||||
# association names for the to-be-preloaded association objects. For
|
# association names for the to-be-preloaded association objects. For
|
||||||
# example, specifying <tt>{ :author => :avatar }</tt> will preload a
|
# example, specifying <tt>{ author: :avatar }</tt> will preload a
|
||||||
# book's author, as well as that author's avatar.
|
# book's author, as well as that author's avatar.
|
||||||
#
|
#
|
||||||
# +:associations+ has the same format as the +:include+ option for
|
# +:associations+ has the same format as the +:include+ option for
|
||||||
@ -80,8 +80,8 @@ class Preloader #:nodoc:
|
|||||||
#
|
#
|
||||||
# :books
|
# :books
|
||||||
# [ :books, :author ]
|
# [ :books, :author ]
|
||||||
# { :author => :avatar }
|
# { author: :avatar }
|
||||||
# [ :books, { :author => :avatar } ]
|
# [ :books, { author: :avatar } ]
|
||||||
def initialize(records, associations, preload_scope = nil)
|
def initialize(records, associations, preload_scope = nil)
|
||||||
@records = Array.wrap(records).compact.uniq
|
@records = Array.wrap(records).compact.uniq
|
||||||
@associations = Array.wrap(associations)
|
@associations = Array.wrap(associations)
|
||||||
|
@ -28,7 +28,7 @@ def target_scope
|
|||||||
# methods which create and delete records on the association.
|
# methods which create and delete records on the association.
|
||||||
#
|
#
|
||||||
# We only support indirectly modifying through associations which has a belongs_to source.
|
# We only support indirectly modifying through associations which has a belongs_to source.
|
||||||
# This is the "has_many :tags, :through => :taggings" situation, where the join model
|
# This is the "has_many :tags, through: :taggings" situation, where the join model
|
||||||
# typically has a belongs_to on both side. In other words, associations which could also
|
# typically has a belongs_to on both side. In other words, associations which could also
|
||||||
# be represented as has_and_belongs_to_many associations.
|
# be represented as has_and_belongs_to_many associations.
|
||||||
#
|
#
|
||||||
|
@ -150,7 +150,7 @@ def supports_statement_cache?
|
|||||||
# already-automatically-released savepoints:
|
# already-automatically-released savepoints:
|
||||||
#
|
#
|
||||||
# Model.connection.transaction do # BEGIN
|
# Model.connection.transaction do # BEGIN
|
||||||
# Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1
|
# Model.connection.transaction(requires_new: true) do # CREATE SAVEPOINT active_record_1
|
||||||
# Model.connection.create_table(...)
|
# Model.connection.create_table(...)
|
||||||
# # active_record_1 now automatically released
|
# # active_record_1 now automatically released
|
||||||
# end # RELEASE SAVEPOINT active_record_1 <--- BOOM! database error!
|
# end # RELEASE SAVEPOINT active_record_1 <--- BOOM! database error!
|
||||||
|
@ -161,21 +161,21 @@ def [](name)
|
|||||||
# td.column(:granted, :boolean)
|
# td.column(:granted, :boolean)
|
||||||
# # granted BOOLEAN
|
# # granted BOOLEAN
|
||||||
#
|
#
|
||||||
# td.column(:picture, :binary, :limit => 2.megabytes)
|
# td.column(:picture, :binary, limit: 2.megabytes)
|
||||||
# # => picture BLOB(2097152)
|
# # => picture BLOB(2097152)
|
||||||
#
|
#
|
||||||
# td.column(:sales_stage, :string, :limit => 20, :default => 'new', :null => false)
|
# td.column(:sales_stage, :string, limit: 20, default: 'new', null: false)
|
||||||
# # => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL
|
# # => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL
|
||||||
#
|
#
|
||||||
# td.column(:bill_gates_money, :decimal, :precision => 15, :scale => 2)
|
# td.column(:bill_gates_money, :decimal, precision: 15, scale: 2)
|
||||||
# # => bill_gates_money DECIMAL(15,2)
|
# # => bill_gates_money DECIMAL(15,2)
|
||||||
#
|
#
|
||||||
# td.column(:sensor_reading, :decimal, :precision => 30, :scale => 20)
|
# td.column(:sensor_reading, :decimal, precision: 30, scale: 20)
|
||||||
# # => sensor_reading DECIMAL(30,20)
|
# # => sensor_reading DECIMAL(30,20)
|
||||||
#
|
#
|
||||||
# # While <tt>:scale</tt> defaults to zero on most databases, it
|
# # While <tt>:scale</tt> defaults to zero on most databases, it
|
||||||
# # probably wouldn't hurt to include it.
|
# # probably wouldn't hurt to include it.
|
||||||
# td.column(:huge_integer, :decimal, :precision => 30)
|
# td.column(:huge_integer, :decimal, precision: 30)
|
||||||
# # => huge_integer DECIMAL(30)
|
# # => huge_integer DECIMAL(30)
|
||||||
#
|
#
|
||||||
# # Defines a column with a database-specific type.
|
# # Defines a column with a database-specific type.
|
||||||
@ -190,11 +190,11 @@ def [](name)
|
|||||||
#
|
#
|
||||||
# What can be written like this with the regular calls to column:
|
# What can be written like this with the regular calls to column:
|
||||||
#
|
#
|
||||||
# create_table "products", :force => true do |t|
|
# create_table "products", force: true do |t|
|
||||||
# t.column "shop_id", :integer
|
# t.column "shop_id", :integer
|
||||||
# t.column "creator_id", :integer
|
# t.column "creator_id", :integer
|
||||||
# t.column "name", :string, :default => "Untitled"
|
# t.column "name", :string, default: "Untitled"
|
||||||
# t.column "value", :string, :default => "Untitled"
|
# t.column "value", :string, default: "Untitled"
|
||||||
# t.column "created_at", :datetime
|
# t.column "created_at", :datetime
|
||||||
# t.column "updated_at", :datetime
|
# t.column "updated_at", :datetime
|
||||||
# end
|
# end
|
||||||
@ -203,7 +203,7 @@ def [](name)
|
|||||||
#
|
#
|
||||||
# create_table :products do |t|
|
# create_table :products do |t|
|
||||||
# t.integer :shop_id, :creator_id
|
# t.integer :shop_id, :creator_id
|
||||||
# t.string :name, :value, :default => "Untitled"
|
# t.string :name, :value, default: "Untitled"
|
||||||
# t.timestamps
|
# t.timestamps
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
@ -218,17 +218,17 @@ def [](name)
|
|||||||
# create_table :taggings do |t|
|
# create_table :taggings do |t|
|
||||||
# t.integer :tag_id, :tagger_id, :taggable_id
|
# t.integer :tag_id, :tagger_id, :taggable_id
|
||||||
# t.string :tagger_type
|
# t.string :tagger_type
|
||||||
# t.string :taggable_type, :default => 'Photo'
|
# t.string :taggable_type, default: 'Photo'
|
||||||
# end
|
# end
|
||||||
# add_index :taggings, :tag_id, :name => 'index_taggings_on_tag_id'
|
# add_index :taggings, :tag_id, name: 'index_taggings_on_tag_id'
|
||||||
# add_index :taggings, [:tagger_id, :tagger_type]
|
# add_index :taggings, [:tagger_id, :tagger_type]
|
||||||
#
|
#
|
||||||
# Can also be written as follows using references:
|
# Can also be written as follows using references:
|
||||||
#
|
#
|
||||||
# create_table :taggings do |t|
|
# create_table :taggings do |t|
|
||||||
# t.references :tag, :index => { :name => 'index_taggings_on_tag_id' }
|
# t.references :tag, index: { name: 'index_taggings_on_tag_id' }
|
||||||
# t.references :tagger, :polymorphic => true, :index => true
|
# t.references :tagger, polymorphic: true, index: true
|
||||||
# t.references :taggable, :polymorphic => { :default => 'Photo' }
|
# t.references :taggable, polymorphic: { default: 'Photo' }
|
||||||
# end
|
# end
|
||||||
def column(name, type, options = {})
|
def column(name, type, options = {})
|
||||||
name = name.to_s
|
name = name.to_s
|
||||||
@ -262,7 +262,7 @@ def #{column_type}(*args) # def string(*args)
|
|||||||
# Adds index options to the indexes hash, keyed by column name
|
# Adds index options to the indexes hash, keyed by column name
|
||||||
# This is primarily used to track indexes that need to be created after the table
|
# This is primarily used to track indexes that need to be created after the table
|
||||||
#
|
#
|
||||||
# index(:account_id, :name => 'index_projects_on_account_id')
|
# index(:account_id, name: 'index_projects_on_account_id')
|
||||||
def index(column_name, options = {})
|
def index(column_name, options = {})
|
||||||
indexes[column_name] = options
|
indexes[column_name] = options
|
||||||
end
|
end
|
||||||
@ -365,9 +365,9 @@ def column_exists?(column_name, type = nil, options = {})
|
|||||||
# ====== Creating a simple index
|
# ====== Creating a simple index
|
||||||
# t.index(:name)
|
# t.index(:name)
|
||||||
# ====== Creating a unique index
|
# ====== Creating a unique index
|
||||||
# t.index([:branch_id, :party_id], :unique => true)
|
# t.index([:branch_id, :party_id], unique: true)
|
||||||
# ====== Creating a named index
|
# ====== Creating a named index
|
||||||
# t.index([:branch_id, :party_id], :unique => true, :name => 'by_branch_party')
|
# t.index([:branch_id, :party_id], unique: true, name: 'by_branch_party')
|
||||||
def index(column_name, options = {})
|
def index(column_name, options = {})
|
||||||
@base.add_index(@table_name, column_name, options)
|
@base.add_index(@table_name, column_name, options)
|
||||||
end
|
end
|
||||||
@ -387,7 +387,7 @@ def timestamps
|
|||||||
# Changes the column's definition according to the new options.
|
# Changes the column's definition according to the new options.
|
||||||
# See TableDefinition#column for details of the options you can use.
|
# See TableDefinition#column for details of the options you can use.
|
||||||
#
|
#
|
||||||
# t.change(:name, :string, :limit => 80)
|
# t.change(:name, :string, limit: 80)
|
||||||
# t.change(:description, :text)
|
# t.change(:description, :text)
|
||||||
def change(column_name, type, options = {})
|
def change(column_name, type, options = {})
|
||||||
@base.change_column(@table_name, column_name, type, options)
|
@base.change_column(@table_name, column_name, type, options)
|
||||||
@ -414,11 +414,11 @@ def remove(*column_names)
|
|||||||
# ====== Remove the index_table_name_on_column in the table_name table
|
# ====== Remove the index_table_name_on_column in the table_name table
|
||||||
# t.remove_index :column
|
# t.remove_index :column
|
||||||
# ====== Remove the index named index_table_name_on_branch_id in the table_name table
|
# ====== Remove the index named index_table_name_on_branch_id in the table_name table
|
||||||
# t.remove_index :column => :branch_id
|
# t.remove_index column: :branch_id
|
||||||
# ====== Remove the index named index_table_name_on_branch_id_and_party_id in the table_name table
|
# ====== Remove the index named index_table_name_on_branch_id_and_party_id in the table_name table
|
||||||
# t.remove_index :column => [:branch_id, :party_id]
|
# t.remove_index column: [:branch_id, :party_id]
|
||||||
# ====== Remove the index named by_branch_party in the table_name table
|
# ====== Remove the index named by_branch_party in the table_name table
|
||||||
# t.remove_index :name => :by_branch_party
|
# t.remove_index name: :by_branch_party
|
||||||
def remove_index(options = {})
|
def remove_index(options = {})
|
||||||
@base.remove_index(@table_name, options)
|
@base.remove_index(@table_name, options)
|
||||||
end
|
end
|
||||||
|
@ -36,10 +36,10 @@ def table_exists?(table_name)
|
|||||||
# index_exists?(:suppliers, [:company_id, :company_type])
|
# index_exists?(:suppliers, [:company_id, :company_type])
|
||||||
#
|
#
|
||||||
# # Check a unique index exists
|
# # 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
|
# # 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 = {})
|
def index_exists?(table_name, column_name, options = {})
|
||||||
column_names = Array(column_name)
|
column_names = Array(column_name)
|
||||||
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, :column => column_names)
|
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, :column => column_names)
|
||||||
@ -89,14 +89,14 @@ def column_exists?(table_name, column_name, type = nil, options = {})
|
|||||||
# # table.
|
# # table.
|
||||||
#
|
#
|
||||||
# create_table(:suppliers) do |t|
|
# create_table(:suppliers) do |t|
|
||||||
# t.column :name, :string, :limit => 60
|
# t.column :name, :string, limit: 60
|
||||||
# # Other fields here
|
# # Other fields here
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# === Block form, with shorthand
|
# === Block form, with shorthand
|
||||||
# # You can also use the column types as method calls, rather than calling the column method.
|
# # You can also use the column types as method calls, rather than calling the column method.
|
||||||
# create_table(:suppliers) do |t|
|
# create_table(:suppliers) do |t|
|
||||||
# t.string :name, :limit => 60
|
# t.string :name, limit: 60
|
||||||
# # Other fields here
|
# # Other fields here
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
@ -104,7 +104,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
|
|||||||
# # Creates a table called 'suppliers' with no columns.
|
# # Creates a table called 'suppliers' with no columns.
|
||||||
# create_table(:suppliers)
|
# create_table(:suppliers)
|
||||||
# # Add a column to '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:
|
# The +options+ hash can include the following keys:
|
||||||
# [<tt>:id</tt>]
|
# [<tt>:id</tt>]
|
||||||
@ -127,15 +127,15 @@ def column_exists?(table_name, column_name, type = nil, options = {})
|
|||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
# ====== Add a backend specific option to the generated SQL (MySQL)
|
# ====== 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:
|
# generates:
|
||||||
# CREATE TABLE suppliers (
|
# CREATE TABLE suppliers (
|
||||||
# id int(11) DEFAULT NULL auto_increment PRIMARY KEY
|
# id int(11) DEFAULT NULL auto_increment PRIMARY KEY
|
||||||
# ) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
# ) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
||||||
#
|
#
|
||||||
# ====== Rename the primary key column
|
# ====== Rename the primary key column
|
||||||
# create_table(:objects, :primary_key => 'guid') do |t|
|
# create_table(:objects, primary_key: 'guid') do |t|
|
||||||
# t.column :name, :string, :limit => 80
|
# t.column :name, :string, limit: 80
|
||||||
# end
|
# end
|
||||||
# generates:
|
# generates:
|
||||||
# CREATE TABLE objects (
|
# CREATE TABLE objects (
|
||||||
@ -144,7 +144,7 @@ def column_exists?(table_name, column_name, type = nil, options = {})
|
|||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# ====== Do not add a primary key column
|
# ====== 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 :category_id, :integer
|
||||||
# t.column :supplier_id, :integer
|
# t.column :supplier_id, :integer
|
||||||
# end
|
# end
|
||||||
@ -193,7 +193,7 @@ def create_table(table_name, options = {})
|
|||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
# ====== Add a backend specific option to the generated SQL (MySQL)
|
# ====== 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:
|
# generates:
|
||||||
# CREATE TABLE assemblies_parts (
|
# CREATE TABLE assemblies_parts (
|
||||||
# assembly_id int NOT NULL,
|
# assembly_id int NOT NULL,
|
||||||
@ -218,7 +218,7 @@ def create_join_table(table_1, table_2, options = {})
|
|||||||
#
|
#
|
||||||
# # change_table() yields a Table instance
|
# # change_table() yields a Table instance
|
||||||
# change_table(:suppliers) do |t|
|
# change_table(:suppliers) do |t|
|
||||||
# t.column :name, :string, :limit => 60
|
# t.column :name, :string, limit: 60
|
||||||
# # Other column alterations here
|
# # Other column alterations here
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
@ -231,12 +231,12 @@ def create_join_table(table_1, table_2, options = {})
|
|||||||
#
|
#
|
||||||
# ====== Add a column
|
# ====== Add a column
|
||||||
# change_table(:suppliers) do |t|
|
# change_table(:suppliers) do |t|
|
||||||
# t.column :name, :string, :limit => 60
|
# t.column :name, :string, limit: 60
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ====== Add 2 integer columns
|
# ====== Add 2 integer columns
|
||||||
# change_table(:suppliers) do |t|
|
# change_table(:suppliers) do |t|
|
||||||
# t.integer :width, :height, :null => false, :default => 0
|
# t.integer :width, :height, null: false, default: 0
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ====== Add created_at/updated_at columns
|
# ====== Add created_at/updated_at columns
|
||||||
@ -253,7 +253,7 @@ def create_join_table(table_1, table_2, options = {})
|
|||||||
#
|
#
|
||||||
# ====== Add a polymorphic foreign key column
|
# ====== Add a polymorphic foreign key column
|
||||||
# change_table(:suppliers) do |t|
|
# change_table(:suppliers) do |t|
|
||||||
# t.belongs_to :company, :polymorphic => true
|
# t.belongs_to :company, polymorphic: true
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Creates <tt>company_type(varchar)</tt> and <tt>company_id(integer)</tt> columns
|
# Creates <tt>company_type(varchar)</tt> and <tt>company_id(integer)</tt> columns
|
||||||
@ -318,7 +318,7 @@ def remove_column(table_name, *column_names)
|
|||||||
# Changes the column's definition according to the new options.
|
# Changes the column's definition according to the new options.
|
||||||
# See TableDefinition#column for details of the options you can use.
|
# 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)
|
# change_column(:accounts, :description, :text)
|
||||||
def change_column(table_name, column_name, type, options = {})
|
def change_column(table_name, column_name, type, options = {})
|
||||||
raise NotImplementedError, "change_column is not implemented"
|
raise NotImplementedError, "change_column is not implemented"
|
||||||
@ -352,35 +352,35 @@ def rename_column(table_name, column_name, new_column_name)
|
|||||||
# CREATE INDEX suppliers_name_index ON suppliers(name)
|
# CREATE INDEX suppliers_name_index ON suppliers(name)
|
||||||
#
|
#
|
||||||
# ====== Creating a unique index
|
# ====== Creating a unique index
|
||||||
# add_index(:accounts, [:branch_id, :party_id], :unique => true)
|
# add_index(:accounts, [:branch_id, :party_id], unique: true)
|
||||||
# generates
|
# generates
|
||||||
# CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id)
|
# CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id)
|
||||||
#
|
#
|
||||||
# ====== Creating a named index
|
# ====== 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
|
# generates
|
||||||
# CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id)
|
# CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id)
|
||||||
#
|
#
|
||||||
# ====== Creating an index with specific key length
|
# ====== 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
|
# generates
|
||||||
# CREATE INDEX by_name ON accounts(name(10))
|
# 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
|
# generates
|
||||||
# CREATE INDEX by_name_surname ON accounts(name(10), surname(15))
|
# CREATE INDEX by_name_surname ON accounts(name(10), surname(15))
|
||||||
#
|
#
|
||||||
# Note: SQLite doesn't support index length
|
# Note: SQLite doesn't support index length
|
||||||
#
|
#
|
||||||
# ====== Creating an index with a sort order (desc or asc, asc is the default)
|
# ====== 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
|
# generates
|
||||||
# CREATE INDEX by_branch_desc_party ON accounts(branch_id DESC, party_id ASC, surname)
|
# 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)
|
# Note: mysql doesn't yet support index order (it accepts the syntax but ignores it)
|
||||||
#
|
#
|
||||||
# ====== Creating a partial index
|
# ====== 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
|
# generates
|
||||||
# CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active
|
# CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active
|
||||||
#
|
#
|
||||||
@ -396,11 +396,11 @@ def add_index(table_name, column_name, options = {})
|
|||||||
# Remove the index_accounts_on_column in the accounts table.
|
# Remove the index_accounts_on_column in the accounts table.
|
||||||
# remove_index :accounts, :column
|
# remove_index :accounts, :column
|
||||||
# Remove the index named index_accounts_on_branch_id in the accounts table.
|
# 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 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 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 = {})
|
def remove_index(table_name, options = {})
|
||||||
remove_index!(table_name, index_name_for_remove(table_name, options))
|
remove_index!(table_name, index_name_for_remove(table_name, options))
|
||||||
end
|
end
|
||||||
|
@ -353,9 +353,9 @@ def recreate_database(name, options = {})
|
|||||||
# Charset defaults to utf8.
|
# Charset defaults to utf8.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# create_database 'charset_test', :charset => 'latin1', :collation => 'latin1_bin'
|
# create_database 'charset_test', charset: 'latin1', collation: 'latin1_bin'
|
||||||
# create_database 'matt_development'
|
# create_database 'matt_development'
|
||||||
# create_database 'matt_development', :charset => :big5
|
# create_database 'matt_development', charset: :big5
|
||||||
def create_database(name, options = {})
|
def create_database(name, options = {})
|
||||||
if options[:collation]
|
if options[:collation]
|
||||||
execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`"
|
execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`"
|
||||||
|
@ -175,7 +175,7 @@ def build_footer(nrows, elapsed)
|
|||||||
# # as values.
|
# # as values.
|
||||||
# def select_one(sql, name = nil)
|
# def select_one(sql, name = nil)
|
||||||
# result = execute(sql, name)
|
# result = execute(sql, name)
|
||||||
# result.each(:as => :hash) do |r|
|
# result.each(as: :hash) do |r|
|
||||||
# return r
|
# return r
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
@ -16,7 +16,7 @@ def recreate_database(name, options = {}) #:nodoc:
|
|||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# create_database config[:database], config
|
# create_database config[:database], config
|
||||||
# create_database 'foo_development', :encoding => 'unicode'
|
# create_database 'foo_development', encoding: 'unicode'
|
||||||
def create_database(name, options = {})
|
def create_database(name, options = {})
|
||||||
options = options.reverse_merge(:encoding => "utf8")
|
options = options.reverse_merge(:encoding => "utf8")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user