回答編集履歴
2
修正
answer
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
---
|
15
15
|
|
16
|
-
```
|
16
|
+
```diff
|
17
17
|
Schema::create('photos', function (Blueprint $table) {
|
18
18
|
- $table->string('id')->primary();
|
19
19
|
+ $table->bigIncrements('id');
|
1
追記
answer
CHANGED
@@ -8,4 +8,22 @@
|
|
8
8
|
|
9
9
|
$table->foreign('user_id')->references('id')->on('users');
|
10
10
|
});
|
11
|
-
```
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
```
|
17
|
+
Schema::create('photos', function (Blueprint $table) {
|
18
|
+
- $table->string('id')->primary();
|
19
|
+
+ $table->bigIncrements('id');
|
20
|
+
$table->unsignedInteger('user_id');
|
21
|
+
$table->string('filename');
|
22
|
+
$table->timestamps();
|
23
|
+
|
24
|
+
$table->foreign('user_id')->references('id')->on('users');
|
25
|
+
|
26
|
+
});
|
27
|
+
```
|
28
|
+
|
29
|
+
問題の原因は、primary にできない string 型を指定していたため、外部キーを付与しようとする以前に、`photos` テーブルの作成で失敗していたため。
|