Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e3d496ac
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e3d496ac
编写于
2月 15, 2020
作者:
D
davidauza-engineer
提交者:
davidauza.engineer
2月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update examples Migration versions to 6.0 [ci skip]
上级
c29afa38
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
20 deletion
+20
-20
activerecord/README.rdoc
activerecord/README.rdoc
+1
-1
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations.rb
+1
-1
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
...record/connection_adapters/abstract/schema_definitions.rb
+1
-1
activerecord/lib/active_record/migration.rb
activerecord/lib/active_record/migration.rb
+16
-16
activerecord/lib/active_record/model_schema.rb
activerecord/lib/active_record/model_schema.rb
+1
-1
未找到文件。
activerecord/README.rdoc
浏览文件 @
e3d496ac
...
...
@@ -140,7 +140,7 @@ This would also define the following accessors: <tt>Product#name</tt> and
* Database agnostic schema management with Migrations.
class AddSystemSettings < ActiveRecord::Migration[
5
.0]
class AddSystemSettings < ActiveRecord::Migration[
6
.0]
def up
create_table :system_settings do |t|
t.string :name
...
...
activerecord/lib/active_record/associations.rb
浏览文件 @
e3d496ac
...
...
@@ -1675,7 +1675,7 @@ def belongs_to(name, scope = nil, **options)
# The join table should not have a primary key or a model associated with it. You must manually generate the
# join table with a migration such as this:
#
# class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration[
5
.0]
# class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration[
6
.0]
# def change
# create_join_table :developers, :projects
# end
...
...
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
浏览文件 @
e3d496ac
...
...
@@ -242,7 +242,7 @@ def #{column_type}(*names, **options)
# Inside migration files, the +t+ object in {create_table}[rdoc-ref:SchemaStatements#create_table]
# is actually of this type:
#
# class SomeMigration < ActiveRecord::Migration[
5
.0]
# class SomeMigration < ActiveRecord::Migration[
6
.0]
# def up
# create_table :foo do |t|
# puts t.class # => "ActiveRecord::ConnectionAdapters::TableDefinition"
...
...
activerecord/lib/active_record/migration.rb
浏览文件 @
e3d496ac
...
...
@@ -19,7 +19,7 @@ def initialize(message = nil)
# For example the following migration is not reversible.
# Rolling back this migration will raise an ActiveRecord::IrreversibleMigration error.
#
# class IrreversibleMigrationExample < ActiveRecord::Migration[
5
.0]
# class IrreversibleMigrationExample < ActiveRecord::Migration[
6
.0]
# def change
# create_table :distributors do |t|
# t.string :zipcode
...
...
@@ -37,7 +37,7 @@ def initialize(message = nil)
#
# 1. Define <tt>#up</tt> and <tt>#down</tt> methods instead of <tt>#change</tt>:
#
# class ReversibleMigrationExample < ActiveRecord::Migration[
5
.0]
# class ReversibleMigrationExample < ActiveRecord::Migration[
6
.0]
# def up
# create_table :distributors do |t|
# t.string :zipcode
...
...
@@ -62,7 +62,7 @@ def initialize(message = nil)
#
# 2. Use the #reversible method in <tt>#change</tt> method:
#
# class ReversibleMigrationExample < ActiveRecord::Migration[
5
.0]
# class ReversibleMigrationExample < ActiveRecord::Migration[
6
.0]
# def change
# create_table :distributors do |t|
# t.string :zipcode
...
...
@@ -202,7 +202,7 @@ def initialize(current: nil, stored: nil)
#
# Example of a simple migration:
#
# class AddSsl < ActiveRecord::Migration[
5
.0]
# class AddSsl < ActiveRecord::Migration[
6
.0]
# def up
# add_column :accounts, :ssl_enabled, :boolean, default: true
# end
...
...
@@ -222,7 +222,7 @@ def initialize(current: nil, stored: nil)
#
# Example of a more complex migration that also needs to initialize data:
#
# class AddSystemSettings < ActiveRecord::Migration[
5
.0]
# class AddSystemSettings < ActiveRecord::Migration[
6
.0]
# def up
# create_table :system_settings do |t|
# t.string :name
...
...
@@ -350,7 +350,7 @@ def initialize(current: nil, stored: nil)
# bin/rails generate migration add_fieldname_to_tablename fieldname:string
#
# This will generate the file <tt>timestamp_add_fieldname_to_tablename.rb</tt>, which will look like this:
# class AddFieldnameToTablename < ActiveRecord::Migration[
5
.0]
# class AddFieldnameToTablename < ActiveRecord::Migration[
6
.0]
# def change
# add_column :tablenames, :fieldname, :string
# end
...
...
@@ -381,7 +381,7 @@ def initialize(current: nil, stored: nil)
#
# Not all migrations change the schema. Some just fix the data:
#
# class RemoveEmptyTags < ActiveRecord::Migration[
5
.0]
# class RemoveEmptyTags < ActiveRecord::Migration[
6
.0]
# def up
# Tag.all.each { |tag| tag.destroy if tag.pages.empty? }
# end
...
...
@@ -394,7 +394,7 @@ def initialize(current: nil, stored: nil)
#
# Others remove columns when they migrate up instead of down:
#
# class RemoveUnnecessaryItemAttributes < ActiveRecord::Migration[
5
.0]
# class RemoveUnnecessaryItemAttributes < ActiveRecord::Migration[
6
.0]
# def up
# remove_column :items, :incomplete_items_count
# remove_column :items, :completed_items_count
...
...
@@ -408,7 +408,7 @@ def initialize(current: nil, stored: nil)
#
# And sometimes you need to do something in SQL not abstracted directly by migrations:
#
# class MakeJoinUnique < ActiveRecord::Migration[
5
.0]
# class MakeJoinUnique < ActiveRecord::Migration[
6
.0]
# def up
# execute "ALTER TABLE `pages_linked_pages` ADD UNIQUE `page_id_linked_page_id` (`page_id`,`linked_page_id`)"
# end
...
...
@@ -425,7 +425,7 @@ def initialize(current: nil, stored: nil)
# <tt>Base#reset_column_information</tt> in order to ensure that the model has the
# latest column data from after the new column was added. Example:
#
# class AddPeopleSalary < ActiveRecord::Migration[
5
.0]
# class AddPeopleSalary < ActiveRecord::Migration[
6
.0]
# def up
# add_column :people, :salary, :integer
# Person.reset_column_information
...
...
@@ -483,7 +483,7 @@ def initialize(current: nil, stored: nil)
# To define a reversible migration, define the +change+ method in your
# migration like this:
#
# class TenderloveMigration < ActiveRecord::Migration[
5
.0]
# class TenderloveMigration < ActiveRecord::Migration[
6
.0]
# def change
# create_table(:horses) do |t|
# t.column :content, :text
...
...
@@ -513,7 +513,7 @@ def initialize(current: nil, stored: nil)
# can't execute inside a transaction though, and for these situations
# you can turn the automatic transactions off.
#
# class ChangeEnum < ActiveRecord::Migration[
5
.0]
# class ChangeEnum < ActiveRecord::Migration[
6
.0]
# disable_ddl_transaction!
#
# def up
...
...
@@ -674,7 +674,7 @@ def initialize(name = self.class.name, version = nil)
# and create the table 'apples' on the way up, and the reverse
# on the way down.
#
# class FixTLMigration < ActiveRecord::Migration[
5
.0]
# class FixTLMigration < ActiveRecord::Migration[
6
.0]
# def change
# revert do
# create_table(:horses) do |t|
...
...
@@ -693,7 +693,7 @@ def initialize(name = self.class.name, version = nil)
#
# require_relative '20121212123456_tenderlove_migration'
#
# class FixupTLMigration < ActiveRecord::Migration[
5
.0]
# class FixupTLMigration < ActiveRecord::Migration[
6
.0]
# def change
# revert TenderloveMigration
#
...
...
@@ -744,7 +744,7 @@ def down
# when the three columns 'first_name', 'last_name' and 'full_name' exist,
# even when migrating down:
#
# class SplitNameMigration < ActiveRecord::Migration[
5
.0]
# class SplitNameMigration < ActiveRecord::Migration[
6
.0]
# def change
# add_column :users, :first_name, :string
# add_column :users, :last_name, :string
...
...
@@ -772,7 +772,7 @@ def reversible
# In the following example, the new column +published+ will be given
# the value +true+ for all existing records.
#
# class AddPublishedToPosts < ActiveRecord::Migration[
5.2
]
# class AddPublishedToPosts < ActiveRecord::Migration[
6.0
]
# def change
# add_column :posts, :published, :boolean, default: false
# up_only do
...
...
activerecord/lib/active_record/model_schema.rb
浏览文件 @
e3d496ac
...
...
@@ -426,7 +426,7 @@ def content_columns
# when just after creating a table you want to populate it with some default
# values, eg:
#
# class CreateJobLevels < ActiveRecord::Migration[
5
.0]
# class CreateJobLevels < ActiveRecord::Migration[
6
.0]
# def up
# create_table :job_levels do |t|
# t.integer :id
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录