When working on a Rails project, there might be scenarios where you want to switch your database from PostgreSQL to SQLite.
SQLite is lightweight, requires no server setup, and is a great choice for development or small-scale projects. This guide walks you through the process step-by-step.
Introduction
Changing your database in a Rails project can seem daunting, but Rails’ flexibility makes it a straightforward task. By following these steps, you'll seamlessly transition from PostgreSQL to SQLite.
Update the Gemfile
First, replace the PostgreSQL gem (pg) with the SQLite gem (sqlite3) in your Gemfile. Here’s how:
# Remove or comment out:
# gem 'pg'
# Add:
gem 'sqlite3', '~> 1.4'
Once updated, run the following command to install the new dependencies:
bundle install
Output
Re-create the structure
rails db:create
rails db:migrate
Output
SOCIAL SHARE CARD GENERATOR