質問編集履歴
1
詳細手順を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,6 +34,160 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
+
### 詳細な手順
|
38
|
+
|
39
|
+
1. `branch_a` で `rails g migration` を実行し、 `rake db:migrate` で、 DBへ反映
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
$ git branch
|
44
|
+
|
45
|
+
* branch_a
|
46
|
+
|
47
|
+
branch_b
|
48
|
+
|
49
|
+
master
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
$ rails g model user name:string
|
54
|
+
|
55
|
+
invoke active_record
|
56
|
+
|
57
|
+
create db/migrate/20170119014258_create_users.rb
|
58
|
+
|
59
|
+
create app/models/user.rb
|
60
|
+
|
61
|
+
invoke test_unit
|
62
|
+
|
63
|
+
create test/models/user_test.rb
|
64
|
+
|
65
|
+
create test/fixtures/users.yml
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
$ rake db:migrate
|
70
|
+
|
71
|
+
== 20170119014258 CreateUsers: migrating ======================================
|
72
|
+
|
73
|
+
-- create_table(:users)
|
74
|
+
|
75
|
+
-> 0.0481s
|
76
|
+
|
77
|
+
== 20170119014258 CreateUsers: migrated (0.0482s) =============================
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
$ git status
|
82
|
+
|
83
|
+
On branch branch_a
|
84
|
+
|
85
|
+
Changes not staged for commit:
|
86
|
+
|
87
|
+
(use "git add <file>..." to update what will be committed)
|
88
|
+
|
89
|
+
(use "git checkout -- <file>..." to discard changes in working directory)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
modified: db/schema.rb
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
Untracked files:
|
98
|
+
|
99
|
+
(use "git add <file>..." to include in what will be committed)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
app/models/user.rb
|
104
|
+
|
105
|
+
db/migrate/20170119014258_create_users.rb
|
106
|
+
|
107
|
+
test/fixtures/users.yml
|
108
|
+
|
109
|
+
test/models/user_test.rb
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
$ git add .
|
114
|
+
|
115
|
+
$ git commit -m "add user model"
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
2.`git checkout branch_b` で `branch_b` に切り替え、 `rake db:migrate` を行う
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
$ git checkout -b branch_b
|
126
|
+
|
127
|
+
$ git branch
|
128
|
+
|
129
|
+
branch_a
|
130
|
+
|
131
|
+
* branch_b
|
132
|
+
|
133
|
+
master
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
$ rake db:migrate #←ここでdiffが発生する
|
138
|
+
|
139
|
+
$ git diff
|
140
|
+
|
141
|
+
diff --git a/db/schema.rb b/db/schema.rb
|
142
|
+
|
143
|
+
index 305532e..1c0d0dc 100644
|
144
|
+
|
145
|
+
--- a/db/schema.rb
|
146
|
+
|
147
|
+
+++ b/db/schema.rb
|
148
|
+
|
149
|
+
@@ -10,7 +10,7 @@
|
150
|
+
|
151
|
+
#
|
152
|
+
|
153
|
+
# It's strongly recommended that you check this file into your version control system.
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
-ActiveRecord::Schema.define(version: 20161230062212) do
|
158
|
+
|
159
|
+
+ActiveRecord::Schema.define(version: 20170119014258) do
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# These are extensions that must be enabled in order to support this database
|
164
|
+
|
165
|
+
enable_extension "plpgsql"
|
166
|
+
|
167
|
+
@@ -29,4 +29,10 @@ ActiveRecord::Schema.define(version: 20161230062212) do
|
168
|
+
|
169
|
+
t.datetime "updated_at", null: false
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
+ create_table "users", force: :cascade do |t|
|
176
|
+
|
177
|
+
+ t.string "name"
|
178
|
+
|
179
|
+
+ t.datetime "created_at", null: false
|
180
|
+
|
181
|
+
+ t.datetime "updated_at", null: false
|
182
|
+
|
183
|
+
+ end
|
184
|
+
|
185
|
+
+
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
```
|
190
|
+
|
37
191
|
|
38
192
|
|
39
193
|
|