質問編集履歴

2

やってみたことの部分のHistoruiesをCustomersに変更しました。

2019/07/29 07:23

投稿

koume
koume

スコア458

test CHANGED
File without changes
test CHANGED
@@ -68,9 +68,9 @@
68
68
 
69
69
  やってみたこと
70
70
 
71
- class CreateHistories < ActiveRecord::Migration[5.1] を
71
+ class CreateCustomers < ActiveRecord::Migration[5.1] を
72
72
 
73
- class CreateHistories < ActiveRecord::Migration[5.0] にして
73
+ class CreateCustomers < ActiveRecord::Migration[5.0] にして
74
74
 
75
75
  migrateしてみましたが変化はありませんでした。
76
76
 

1

記述したテーブルの変更

2019/07/29 07:23

投稿

koume
koume

スコア458

test CHANGED
File without changes
test CHANGED
@@ -24,31 +24,39 @@
24
24
 
25
25
  ```ここに言語を入力
26
26
 
27
- class CreateHistories < ActiveRecord::Migration[5.1]
27
+ class CreateCustomers < ActiveRecord::Migration[5.1]
28
28
 
29
29
  def change
30
30
 
31
- create_table :histories do |t|
31
+ create_table :customers do |t|
32
32
 
33
- t.integer :customer_id
33
+ t.string :email, null: false #メールアドレス
34
34
 
35
- t.string :nick_name
35
+ t.string :email_for_index, null: false
36
36
 
37
- t.string :reservation, null: false, default: "注文kgを選択"
37
+ t.string :family_name, null: false
38
38
 
39
- t.string :undispatched, null: false, default: "未発送"
39
+ t.string :given_name, null: false
40
40
 
41
- t.integer :year
41
+ t.string :family_name_kana, null: false
42
42
 
43
- t.integer :month
43
+ t.string :given_name_kana, null: false
44
44
 
45
+ t.string :nick_name, null: false
46
+
45
- t.integer :day
47
+ t.string :hashed_password
46
48
 
47
49
  t.timestamps
48
50
 
49
51
  end
50
52
 
53
+
54
+
55
+ add_index :customers, :email_for_index, unique: true
56
+
51
- add_index :histories, :reservation
57
+ add_index :customers, :nick_name, unique: true
58
+
59
+ add_index :customers, [ :family_name_kana, :given_name_kana ]
52
60
 
53
61
  end
54
62