Rideshare is the Rails application for: High Performance PostgreSQL for Rails
Prepare your development machine.
First, install Homebrew.
brew install graphviz
Before installing Ruby, install a Ruby version manager. The recommended one is Rbenv. Install:
brew install rbenv
If you've installed version 16 of PostgreSQL via Homebrew, that's fine. If not:
- Install Postgres.app, which is the recommended method
- From the Menu Bar app, click "+", then add a PostgreSQL 16 server
PostgreSQL configuration follows: My GOTO Postgres Configuration for Web Services
Run cat .ruby-version
to find the version of Ruby that Rideshare uses.
To install 3.2.2
, run:
rbenv install 3.2.2
Run rbenv versions
to confirm the correct version is used (has an asterisk):
system
* 3.2.2 (set by /Users/andy/Projects/rideshare/.ruby-version)
Running into trouble? Review Learn how to load rbenv in your shell. using rbenv init
.
Bundler is included when you install Ruby using Rbenv. You're ready to install gems:
bundle install
Normally in Rails, you'd run bin/rails db:create
. Rideshare uses a custom script.
To create the database and objects, you'll use db/setup.sh
Before running it, ensure the following environment variables are set:
RIDESHARE_DB_PASSWORD
DB_URL
Review the script comment header section for more information on the values.
Once you've both environment variables, run the script as follows. This version captures output to output.log
.
sh db/setup.sh 2>&1 | tee -a output.log
Since you set RIDESHARE_DB_PASSWORD
earlier, create or update the file ~/.pgpass
and add the password value. Refer to postgresql/.pgpass.sample
for a sample entry.
When you've updated it, ~/.pgpass
should look as follows. Replace the last segment 2C6uw3LprgUMwSLQ
below with the password value you generated.
localhost:5432:rideshare_development:owner:2C6uw3LprgUMwSLQ
Run chmod 0600 ~/.pgpass
.
Finally, run export DATABASE_URL=<value from .env>
, setting the value from the .env
file. Once that's set:
Verify you can connect by running: psql $DATABASE_URL
. Once connected, run this from psql:
SELECT current_user;
Confirm you're connected as owner
. Then run the describe namespace meta-command:
\dn
Verify the rideshare
schema is visible. Run the describe table meta command: \dt
to view the Rideshare tables.
Migrations in Rideshare are preceded by SET role = owner
, so they run as owner
. This user owns the tables.
See: lib/tasks/migration_hooks.rake
Run migrations the standard way:
bin/rails db:migrate
If the tables were created successfully in the rideshare
schema, you're good to go!
The Rideshare repository has many README.md
files within subdirectories. Run find . -name 'README.md'
to list them.
- For expanded installation and troubleshooting, navigate to the Development Guides go into greater depth for preparing your development machine.
- For PostgreSQL things: postgresql/README.md
- For Docker things: docker/README.md
- For DB things: db/README.md
- For database scripts: db/scripts/README.md
- For DB scrubbing: db/scrubbing/README.md
- For test environment details in Rideshare, check out: TESTING.md
- For Guides and Tasks in this repo, check out: Guides
Although Rideshare is an API-only app, there are some UI elements.
Rideshare runs PgHero which has a UI.
Connect to it:
bin/rails server
Once that's running, visit http://localhost:3000/pghero in your browser.