質問編集履歴
2
マイグレーションファイルの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,4 +39,175 @@
|
|
39
39
|
DB_DATABASE=
|
40
40
|
DB_USERNAME=<マスターユーザー名>
|
41
41
|
DB_PASSWORD=<パスワード>
|
42
|
+
```
|
43
|
+
|
44
|
+
マイグレーション対象ファイルは以下です。
|
45
|
+
```
|
46
|
+
<?php
|
47
|
+
|
48
|
+
use Illuminate\Support\Facades\Schema;
|
49
|
+
use Illuminate\Database\Schema\Blueprint;
|
50
|
+
use Illuminate\Database\Migrations\Migration;
|
51
|
+
|
52
|
+
class CreateUsersTable extends Migration
|
53
|
+
{
|
54
|
+
/**
|
55
|
+
* Run the migrations.
|
56
|
+
*
|
57
|
+
* @return void
|
58
|
+
*/
|
59
|
+
public function up()
|
60
|
+
{
|
61
|
+
Schema::create('users', function (Blueprint $table) {
|
62
|
+
$table->increments('id');
|
63
|
+
$table->string('name');
|
64
|
+
$table->integer('stance')->default(1);
|
65
|
+
$table->integer('board')->default(1);
|
66
|
+
$table->string('introduction')->nullable();
|
67
|
+
$table->string('image_path')->nullable();
|
68
|
+
$table->string('email')->unique();
|
69
|
+
$table->timestamp('email_verified_at')->nullable();
|
70
|
+
$table->string('password');
|
71
|
+
$table->rememberToken();
|
72
|
+
$table->timestamps();
|
73
|
+
});
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Reverse the migrations.
|
78
|
+
*
|
79
|
+
* @return void
|
80
|
+
*/
|
81
|
+
public function down()
|
82
|
+
{
|
83
|
+
Schema::dropIfExists('users');
|
84
|
+
}
|
85
|
+
}
|
86
|
+
```
|
87
|
+
```ここに言語を入力
|
88
|
+
<?php
|
89
|
+
|
90
|
+
use Illuminate\Support\Facades\Schema;
|
91
|
+
use Illuminate\Database\Schema\Blueprint;
|
92
|
+
use Illuminate\Database\Migrations\Migration;
|
93
|
+
|
94
|
+
class CreateSpotsTable extends Migration
|
95
|
+
{
|
96
|
+
/**
|
97
|
+
* Run the migrations.
|
98
|
+
*
|
99
|
+
* @return void
|
100
|
+
*/
|
101
|
+
public function up()
|
102
|
+
{
|
103
|
+
Schema::create('spots', function (Blueprint $table) {
|
104
|
+
$table->increments('id');
|
105
|
+
$table->integer('user_id')->unsigned();
|
106
|
+
$table->string('name');
|
107
|
+
$table->string('place');
|
108
|
+
$table->string('body');
|
109
|
+
$table->timestamps();
|
110
|
+
|
111
|
+
// 外部キーを設定する
|
112
|
+
$table->foreign('user_id')->references('id')->on('users');
|
113
|
+
});
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Reverse the migrations.
|
118
|
+
*
|
119
|
+
* @return void
|
120
|
+
*/
|
121
|
+
public function down()
|
122
|
+
{
|
123
|
+
Schema::dropIfExists('spots');
|
124
|
+
}
|
125
|
+
}
|
126
|
+
```
|
127
|
+
```ここに言語を入力
|
128
|
+
<?php
|
129
|
+
|
130
|
+
use Illuminate\Support\Facades\Schema;
|
131
|
+
use Illuminate\Database\Schema\Blueprint;
|
132
|
+
use Illuminate\Database\Migrations\Migration;
|
133
|
+
|
134
|
+
class CreateDiariesTable extends Migration
|
135
|
+
{
|
136
|
+
/**
|
137
|
+
* Run the migrations.
|
138
|
+
*
|
139
|
+
* @return void
|
140
|
+
*/
|
141
|
+
public function up()
|
142
|
+
{
|
143
|
+
Schema::create('diaries', function (Blueprint $table) {
|
144
|
+
$table->increments('id');
|
145
|
+
$table->integer('spot_id')->unsigned();
|
146
|
+
$table->integer('user_id')->unsigned();
|
147
|
+
$table->string('title');
|
148
|
+
$table->integer('score');
|
149
|
+
$table->integer('condition');
|
150
|
+
$table->integer('size');
|
151
|
+
$table->string('body');
|
152
|
+
$table->string('image_path')->nullable();
|
153
|
+
$table->timestamps();
|
154
|
+
|
155
|
+
// 外部キー設定
|
156
|
+
$table->foreign('spot_id')->references('id')->on('spots');
|
157
|
+
$table->foreign('user_id')->references('id')->on('users');
|
158
|
+
});
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Reverse the migrations.
|
163
|
+
*
|
164
|
+
* @return void
|
165
|
+
*/
|
166
|
+
public function down()
|
167
|
+
{
|
168
|
+
Schema::dropIfExists('diaries');
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
```
|
173
|
+
```ここに言語を入力
|
174
|
+
<?php
|
175
|
+
|
176
|
+
use Illuminate\Support\Facades\Schema;
|
177
|
+
use Illuminate\Database\Schema\Blueprint;
|
178
|
+
use Illuminate\Database\Migrations\Migration;
|
179
|
+
|
180
|
+
class CreateCommentsTable extends Migration
|
181
|
+
{
|
182
|
+
/**
|
183
|
+
* Run the migrations.
|
184
|
+
*
|
185
|
+
* @return void
|
186
|
+
*/
|
187
|
+
public function up()
|
188
|
+
{
|
189
|
+
Schema::create('comments', function (Blueprint $table) {
|
190
|
+
$table->increments('id');
|
191
|
+
$table->integer('user_id')->unsigned();
|
192
|
+
$table->integer('diary_id')->unsigned();
|
193
|
+
$table->string('body');
|
194
|
+
$table->timestamps();
|
195
|
+
|
196
|
+
//外部キー
|
197
|
+
$table->foreign('user_id')->references('id')->on('users');
|
198
|
+
$table->foreign('diary_id')->references('id')->on('diaries');
|
199
|
+
});
|
200
|
+
}
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Reverse the migrations.
|
204
|
+
*
|
205
|
+
* @return void
|
206
|
+
*/
|
207
|
+
public function down()
|
208
|
+
{
|
209
|
+
Schema::dropIfExists('comments');
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
42
213
|
```
|
1
envの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,4 +29,14 @@
|
|
29
29
|
Please use the argument -v to see more details.
|
30
30
|
```
|
31
31
|
と表示され実行できません。
|
32
|
-
unix_socketあたりが問題なのでしょうか?
|
32
|
+
unix_socketあたりが問題なのでしょうか?
|
33
|
+
|
34
|
+
.envは以下で設定しています。
|
35
|
+
```env
|
36
|
+
DB_CONNECTION=mysql
|
37
|
+
DB_HOST=<エンドポイント>
|
38
|
+
DB_PORT=3306
|
39
|
+
DB_DATABASE=
|
40
|
+
DB_USERNAME=<マスターユーザー名>
|
41
|
+
DB_PASSWORD=<パスワード>
|
42
|
+
```
|