teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

fad

2017/05/05 11:54

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -20,8 +20,8 @@
20
20
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
21
21
  ```
22
22
 
23
-
24
- ```CreateOrdersTable
23
+ # CreateOrdersTable
24
+ ```
25
25
  <?php
26
26
 
27
27
  use Illuminate\Support\Facades\Schema;
@@ -65,8 +65,8 @@
65
65
  }
66
66
  ```
67
67
 
68
-
69
- ```CreateProductsTable
68
+ #CreateProductsTable
69
+ ```
70
70
  <?php
71
71
 
72
72
  use Illuminate\Support\Facades\Schema;
@@ -107,8 +107,8 @@
107
107
  }
108
108
  ```
109
109
 
110
-
111
- ```CreateCustomersTable
110
+ #CreateCustomersTable
111
+ ```
112
112
  <?php
113
113
 
114
114
  use Illuminate\Support\Facades\Schema;

3

fad

2017/05/05 11:54

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -21,7 +21,7 @@
21
21
  ```
22
22
 
23
23
 
24
- ```
24
+ ```CreateOrdersTable
25
25
  <?php
26
26
 
27
27
  use Illuminate\Support\Facades\Schema;
@@ -66,7 +66,7 @@
66
66
  ```
67
67
 
68
68
 
69
- ```
69
+ ```CreateProductsTable
70
70
  <?php
71
71
 
72
72
  use Illuminate\Support\Facades\Schema;
@@ -108,7 +108,7 @@
108
108
  ```
109
109
 
110
110
 
111
- ```
111
+ ```CreateCustomersTable
112
112
  <?php
113
113
 
114
114
  use Illuminate\Support\Facades\Schema;

2

fa

2017/05/05 11:54

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -63,4 +63,100 @@
63
63
  Schema::dropIfExists('orders');
64
64
  }
65
65
  }
66
+ ```
67
+
68
+
69
+ ```
70
+ <?php
71
+
72
+ use Illuminate\Support\Facades\Schema;
73
+ use Illuminate\Database\Schema\Blueprint;
74
+ use Illuminate\Database\Migrations\Migration;
75
+
76
+ class CreateProductsTable extends Migration
77
+ {
78
+ /**
79
+ * Run the migrations.
80
+ *
81
+ * @return void
82
+ */
83
+ public function up()
84
+ {
85
+ Schema::create('products', function (Blueprint $table) {
86
+ $table->increments('product_id');
87
+ $table->string('product_name')->unique("product_name");
88
+ $table->timestamps();
89
+ $table->softDeletes();
90
+
91
+
92
+
93
+
94
+
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Reverse the migrations.
100
+ *
101
+ * @return void
102
+ */
103
+ public function down()
104
+ {
105
+ Schema::dropIfExists('products');
106
+ }
107
+ }
108
+ ```
109
+
110
+
111
+ ```
112
+ <?php
113
+
114
+ use Illuminate\Support\Facades\Schema;
115
+ use Illuminate\Database\Schema\Blueprint;
116
+ use Illuminate\Database\Migrations\Migration;
117
+
118
+ class CreateCustomersTable extends Migration
119
+ {
120
+ /**
121
+ * Run the migrations.
122
+ *
123
+ * @return void
124
+ */
125
+ public function up()
126
+ {
127
+ Schema::create('customers', function (Blueprint $table) {
128
+ $table->increments('customer_id');
129
+
130
+ $table->integer("building_id")->unsigned();
131
+ $table->foreign('building_id')->references('building_id')->on('buildings');
132
+
133
+ $table->integer("room_id")->unsigned();
134
+ $table->foreign('room_id')->references('room_id')->on('rooms');
135
+
136
+ $table->string("last_name")->nullable();
137
+ $table->string("first_name")->nullable();
138
+
139
+ $table->string("phone_number")->nullable();
140
+ $table->enum("choices", ["male, female"]);
141
+ $table->text('memo')->nullable();
142
+
143
+ $table->timestamps();
144
+ $table->softDeletes();
145
+
146
+
147
+
148
+ });
149
+ }
150
+
151
+ /**
152
+ * Reverse the migrations.
153
+ *
154
+ * @return void
155
+ */
156
+ public function down()
157
+ {
158
+ Schema::dropIfExists('customers');
159
+ }
160
+ }
161
+
66
162
  ```

1

r

2017/05/05 11:53

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
File without changes