質問編集履歴
1
followersテーブルを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -147,5 +147,45 @@
|
|
147
147
|
|
148
148
|
### 補足情報(FW/ツールのバージョンなど)
|
149
149
|
|
150
|
-
|
150
|
+
```migrations\Y_m_d_t_create_followers_table.php
|
151
|
+
<?php
|
151
152
|
|
153
|
+
use Illuminate\Database\Migrations\Migration;
|
154
|
+
use Illuminate\Database\Schema\Blueprint;
|
155
|
+
use Illuminate\Support\Facades\Schema;
|
156
|
+
|
157
|
+
return new class extends Migration
|
158
|
+
{
|
159
|
+
/**
|
160
|
+
* Run the migrations.
|
161
|
+
*
|
162
|
+
* @return void
|
163
|
+
*/
|
164
|
+
public function up()
|
165
|
+
{
|
166
|
+
Schema::create('followers', function (Blueprint $table) {
|
167
|
+
$table->unsignedInteger('following_id')->comment('フォローしているユーザID');
|
168
|
+
$table->unsignedInteger('followed_id')->comment('フォローされているユーザID');
|
169
|
+
|
170
|
+
$table->index('following_id');
|
171
|
+
$table->index('followed_id');
|
172
|
+
|
173
|
+
$table->unique([
|
174
|
+
'following_id',
|
175
|
+
'followed_id'
|
176
|
+
]);
|
177
|
+
});
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Reverse the migrations.
|
182
|
+
*
|
183
|
+
* @return void
|
184
|
+
*/
|
185
|
+
public function down()
|
186
|
+
{
|
187
|
+
Schema::dropIfExists('followers');
|
188
|
+
}
|
189
|
+
};
|
190
|
+
```
|
191
|
+
|