LoginSignup
14
12

More than 3 years have passed since last update.

[Rails]本番環境EC2で"rails db:create"などの実行方法

Posted at

投稿内容

ローカル環境で行うrails db:createrails db:migrateなどを本番環境で実行する方法について投稿します。

実行するディレクトリへ移動

まず本番環境で下記コマンドでcurrentディレクトリまで移動します。

ターミナル.
[ec2-user@******* ~]$ cd /var/www/アプリ名/current

コマンド実行

ターミナル.
//データベースを削除
[ec2-user@******* current]$ RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake db:drop

//データベース作成
[ec2-user@******* current]$ rails db:create RAILS_ENV=production

//テーブル、カラムの作成
[ec2-user@******* current]$ rails db:migrate RAILS_ENV=production

//データベースのカラムに情報を送りたい場合
[ec2-user@******* current]$ rails db:seed RAILS_ENV=production

最後に

本番環境のコマンドはついつい忘れてしまいそうになるので、是非参考にしてもらえると幸いです!

14
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12