DEV Community

Andres Becker
Andres Becker

Posted on

Creating a new database in Rails

To create a new database in Rails, you can use the rails db:create command. This will create a new database for your Rails application using the database adapter and settings specified in your config/database.yml file. For example, if you are using SQLite as your database, you would run the following command:

rails db:create
Enter fullscreen mode Exit fullscreen mode

This will create a new database for your Rails application in the db directory — SQLite by default, but you may have configured a different database already, such as Postgresql. You can then use the rails db:migrate command to run any pending database migrations, which will set up the necessary tables and schema for your application.

Keep in mind that you will need to have a database server installed and running on your system in order to use this command. If you are using a database other than SQLite, you will also need to ensure that the necessary database drivers and libraries are installed on your system.

Top comments (0)