質問編集履歴

1

マイグレーションファイルを追記

2020/10/30 02:28

投稿

pup-ganbaru
pup-ganbaru

スコア29

test CHANGED
File without changes
test CHANGED
@@ -143,3 +143,131 @@
143
143
  }
144
144
 
145
145
  ```
146
+
147
+
148
+
149
+ マイグレーションファイル
150
+
151
+
152
+
153
+ site_user_table.php
154
+
155
+ ```ここに言語を入力
156
+
157
+ */
158
+
159
+ public function up()
160
+
161
+ {
162
+
163
+ Schema::create('site_user', function (Blueprint $table) {
164
+
165
+ $table->id();
166
+
167
+ $table->timestamps();
168
+
169
+ });
170
+
171
+ }
172
+
173
+
174
+
175
+ ```
176
+
177
+
178
+
179
+ add column site_user table php
180
+
181
+ ```ここに言語を入力
182
+
183
+ */
184
+
185
+ public function up()
186
+
187
+ {
188
+
189
+ Schema::table('site_user', function (Blueprint $table) {
190
+
191
+ $table->unsignedBigInteger('user_id');
192
+
193
+ $table->unsignedBigInteger('site_id');
194
+
195
+ $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
196
+
197
+ $table->foreign('site_id')->references('id')->on('sites')->onDelete('cascade');
198
+
199
+ });
200
+
201
+ }
202
+
203
+ ```
204
+
205
+
206
+
207
+
208
+
209
+ user table php
210
+
211
+ ```ここに言語を入力
212
+
213
+ public function up()
214
+
215
+ {
216
+
217
+ Schema::create('users', function (Blueprint $table) {
218
+
219
+ $table->id();
220
+
221
+ $table->string('name');
222
+
223
+ $table->string('email')->unique();
224
+
225
+ $table->timestamp('email_verified_at')->nullable();
226
+
227
+ $table->string('password');
228
+
229
+ $table->rememberToken();
230
+
231
+ $table->foreignId('current_team_id')->nullable();
232
+
233
+ $table->text('profile_photo_path')->nullable();
234
+
235
+ $table->timestamps();
236
+
237
+ });
238
+
239
+ }
240
+
241
+
242
+
243
+ ```
244
+
245
+
246
+
247
+ site table php
248
+
249
+ ```ここに言語を入力
250
+
251
+ public function up()
252
+
253
+ {
254
+
255
+ Schema::create('sites', function (Blueprint $table) {
256
+
257
+ $table->id();
258
+
259
+ $table->string('site_name');
260
+
261
+ $table->string('site_url');
262
+
263
+ $table->boolean('delete_flg');
264
+
265
+ $table->softDeletes();
266
+
267
+ $table->timestamps();
268
+
269
+ });
270
+
271
+ }
272
+
273
+ ```