[RUBY] [Rails] How to execute "rails db: create" etc. in production environment EC2

Posted content

I will post about how to run rails db: create, rails db: migrate, etc. in the local environment in the production environment.

Move to the directory to execute

First, in the production environment, move to the current directory with the following command.


[[email protected]******* ~]$ cd /var/www/app name/current

Command execution


//Delete database
[[email protected]******* current]$ RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake db:drop

//Database creation
[[email protected]******* current]$ rails db:create RAILS_ENV=production

//Creating tables and columns
[[email protected]******* current]$ rails db:migrate RAILS_ENV=production

//If you want to send information to a column in the database
[[email protected]******* current]$ rails db:seed RAILS_ENV=production


It's easy to forget the commands in the production environment, so I hope you'll find it helpful!

Recommended Posts

[Rails] How to execute "rails db: create" etc. in production environment EC2
How to reflect seeds.rb in production environment
[Rails] How to reset the database in production environment (Capistrano version)
How to easily create a pull-down in Rails
Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to use PostgreSQL in Vagrant environment
[Ruby On Rails] How to reset DB in Heroku
[Rails] How to delete production environment MySQL data after putting it in the development environment
[rails] How to display db information
[Rails] How to write in Japanese
Create a database in a production environment
How to introduce jQuery in Rails 6
How to install Swiper in Rails
Can't output PDF in production environment (EC2, Amazon Linux) with Rails
How to implement search functionality in Rails
How to change app name in rails
How to use custom helpers in rails
How to insert a video in Rails
How to use MySQL in Rails tutorial
[rails] How to configure routing in resources
[Note] Update to production environment (AWS EC2)
[rails] How to create a partial template
How to implement ranking functionality in Rails
How to use environment variables in RubyOnRails
[Rails] Reset the database in the production environment
How to use credentials.yml.enc introduced in Rails 5.2
How to execute multiple commands in docker-compose.yml
How to build Rails 6 environment with Docker
How to create a query using variables in GraphQL [Using Ruby on Rails]
How to execute with commands of normal development language in Docker development environment
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
[Rails] How to create a graph using lazy_high_charts
How to link Rails6 Vue (from environment construction)
[Rails] How to use select boxes in Ransack
rails tutorial About account activation in production environment
Rails5.1 + puma SSL connection in local production environment
How to install Titan2D (v4.2.0) in virtual environment
How to translate Rails into Japanese in general
How to prevent direct URL typing in Rails
How to create a theme in Liferay 7 / DXP
How to separate .scss by controller in Rails
How to conditionally add html.erb class in Rails
How to implement a like feature in Rails
500 Internal Server Error occurs in Rails production environment
[Rails] How to create a Twitter share button
How to use JQuery in js.erb of Rails6
[Rails MySQL] How to reset DB on heroku
[Ruby on Rails] How to install Bootstrap in Rails
[Rails] How to build an environment with Docker
How to make a follow function in Rails
How to execute tasks in parallel in Swift in Swift Package
How to check Rails commands in the terminal
How to redirect to http-> https when SSL is enabled in Rails × Heroku environment
How to set the display time to Japan time in Rails
How to implement guest login in 5 minutes in rails portfolio
[Rails] How to create a signed URL for CloudFront
How to implement a like feature in Ajax in Rails
[Ruby on Rails] How to write enum in Japanese
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
How to write Rails
How to create a Spring Boot project in IntelliJ