1

I try to change the name of database and application name in Rails. What is the shortcut for it by changing all the depended classes and configuration values?

3 Answers 3

1

I am not sure but I think we can't change database name. You need to follow some steps in rails application:

  1. Take dump of your existing database
  2. Create a new database (postgres=# CREATE DATABASE new_database_name;)
  3. Restore your dump in new database
  4. Manually change database name in app/config/database.yml
  5. Run Migrations rails db:migrate
  6. Finally drop the older existing database (if you want)
Sign up to request clarification or add additional context in comments.

Comments

0

I really don't think there are any shortcuts built into rails to change the name of the entire project as well as the database, but luckily it really isn't that hard to make the change.

Once you've edited the application.rb file and the database.yml file, you should just do a quick find and replace in project call on your project to change any other necessary references.

Comments

0

I don't think it's possible for the database.

You can use mysqldump to dump the data and then create a schema with your new name and then dump the data into that new database

Then after dumping the data into the database just change the new database name in your database.yml

You can find the refrence below: https://dev.mysql.com/doc/refman/5.7/en/mysqldump-sql-format.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.