質問編集履歴
1
実装した具体的な手順の流れの記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,60 @@
|
|
2
2
|
|
3
3
|
現在herokuデプロイを行う過程の中でデータベースの設定としてテーブルを作成するところでエラーが発生し止まっている状態です。
|
4
4
|
heroku run bin/rails db:migrateの入力でエラーが発生しています。
|
5
|
+
具体的な自分の行なったこととしては下記の通りです。
|
6
|
+
```
|
7
|
+
$heroku login
|
8
|
+
$ heroku create
|
9
|
+
$ git push heroku testbranch:master
|
10
|
+
```
|
11
|
+
Herokuにクレジット登録
|
12
|
+
```
|
13
|
+
$ heroku addons:create jawsdb:kitefin
|
5
14
|
|
15
|
+
`config/database.yml`にある`production`の設定情報を以下のよう追加
|
16
|
+
production:
|
17
|
+
<<: *default
|
18
|
+
url: <%= ENV['JAWSDB_URL']&.sub('mysql://', 'mysql2://') %>
|
19
|
+
|
20
|
+
$ git commit -a -m "Look for env var defined by JAWSDB addon on production"
|
21
|
+
$ git push heroku testbranch:master
|
22
|
+
```
|
23
|
+
aws Iamユーザーの作成
|
24
|
+
>User nameは`sample`
|
25
|
+
>Access typeは`Programmatic access`にチェックを入れる
|
26
|
+
>Add permission -> Attach existing policies directly から`AmazonS3FullAccess`を選択する
|
27
|
+
>Tagは追加なし
|
28
|
+
```
|
29
|
+
$ brew install awscli
|
30
|
+
$ aws configure
|
31
|
+
AWS Access Key ID [None]: (ユーザーのAccess key ID)
|
32
|
+
AWS Secret Access Key [None]: (ユーザーのSecret access key)
|
33
|
+
Default region name [None]: ap-northeast-1
|
34
|
+
Default output format [None]: json
|
35
|
+
$aws s3 mb s3://sample1
|
36
|
+
$aws s3api put-bucket-acl --bucket sample1 --acl public-read
|
37
|
+
aws s3 ls
|
38
|
+
```
|
39
|
+
`config/storage.yml`のamazonの項目のコメントアウトを外し
|
40
|
+
```
|
41
|
+
amazon:
|
42
|
+
service: S3
|
43
|
+
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
|
44
|
+
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
|
45
|
+
region: ap-northeast-1
|
46
|
+
bucket: バケット名
|
47
|
+
```
|
48
|
+
gemlfileに追加
|
49
|
+
gem "aws-sdk-s3", require: false
|
50
|
+
ターミナルで bundle install
|
51
|
+
|
52
|
+
```
|
53
|
+
$ heroku config:set AWS_ACCESS_KEY_ID=(ユーザーのAccess key ID) AWS_SECRET_ACCESS_KEY=(ユーザーのSecret access key)
|
54
|
+
$ git commit -a -m "Configure Active Storage to use S3"
|
55
|
+
$ git push heroku testbranch:master
|
56
|
+
$ heroku run bin/rails db:migrate #ここの箇所でエラーが生じる
|
57
|
+
```
|
58
|
+
|
6
59
|
### 発生している問題・エラーメッセージ
|
7
60
|
|
8
61
|
```
|