{"id":13878076,"url":"https://github.com/andyatkinson/rideshare","last_synced_at":"2025-05-16T15:09:14.651Z","repository":{"id":40007562,"uuid":"221023180","full_name":"andyatkinson/rideshare","owner":"andyatkinson","description":"Rails app used in book 📚 \"High Performance PostgreSQL for Rails\"","archived":false,"fork":false,"pushed_at":"2025-04-05T15:33:23.000Z","size":18513,"stargazers_count":223,"open_issues_count":9,"forks_count":78,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-12T14:55:18.607Z","etag":null,"topics":["postgresql","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://andyatkinson.com/pgrailsbook","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyatkinson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-11T16:30:44.000Z","updated_at":"2025-04-10T04:50:06.000Z","dependencies_parsed_at":"2024-04-27T18:24:44.063Z","dependency_job_id":"e4334aff-62aa-4768-b384-04a1e4f80363","html_url":"https://github.com/andyatkinson/rideshare","commit_stats":{"total_commits":461,"total_committers":7,"mean_commits":65.85714285714286,"dds":0.03470715835141003,"last_synced_commit":"5841208cffd50bef90a4a5b86930c5cbaaa04b6a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Frideshare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Frideshare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Frideshare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Frideshare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyatkinson","download_url":"https://codeload.github.com/andyatkinson/rideshare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553958,"owners_count":22090417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgresql","ruby","ruby-on-rails"],"created_at":"2024-08-06T08:01:39.204Z","updated_at":"2025-05-16T15:09:09.642Z","avatar_url":"https://github.com/andyatkinson.png","language":"Ruby","readme":"[![CircleCI](https://circleci.com/gh/andyatkinson/rideshare.svg?style=svg)](https://circleci.com/gh/andyatkinson/rideshare)\n\n# 📚 High Performance PostgreSQL for Rails\nRideshare is the Rails application supporting the book \"High Performance PostgreSQL for Rails\" \u003chttp://pragprog.com/titles/aapsql\u003e, published by Pragmatic Programmers in 2024. \n\n# Installation\nPrepare your development machine.\n\n\u003cdetails\u003e\n\u003csummary\u003e🎥 Installation - Rideshare on a Mac, Ruby, PostgreSQL, Gems\u003c/summary\u003e\n\u003cdiv\u003e\n  \u003ca href=\"https://www.loom.com/share/8bfc4e79758a42d39cead8f6637aa314\"\u003e\n    \u003cimg style=\"max-width:300px;\" src=\"https://cdn.loom.com/sessions/thumbnails/8bfc4e79758a42d39cead8f6637aa314-1714771702452-with-play.gif\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003c/details\u003e\n\n## Homebrew Packages\nFirst, install [Homebrew](https://brew.sh).\n\n### Graphviz\n```sh\nbrew install graphviz\n```\n\n## Ruby Version Manager\nBefore installing Ruby, install a *Ruby version manager*. The recommended one is [Rbenv](https://github.com/rbenv/rbenv). Run:\n\n```sh\nbrew install rbenv\n```\n\n## PostgreSQL\nPostgreSQL 16 or greater is required. Installation may be via Homebrew, although the recommended method is [Postgres.app](https://postgresapp.com)\n\n### PostgresApp\n- Once installed, from the Menu Bar app, choose \"Open Postgres\" then click the \"+\" icon to create a new PostgreSQL 16 server\n\n\n## Ruby\nRun `cat .ruby-version` from the Rideshare directory to find the needed version of Ruby.\n\nFor example, if `3.2.2` is listed, run:\n\n```sh\nrbenv install 3.2.2\n```\n\nRun `rbenv versions` to confirm the correct version is active. The current version has an asterisk.\n\n```sh\n  system\n* 3.2.2 (set by /Users/andy/Projects/rideshare/.ruby-version)\n```\n\nRunning into rbenv trouble? Review *Learn how to load rbenv in your shell* using [`rbenv init`](https://github.com/rbenv/rbenv).\n\n## Bundler and Gems\nBundler is included when you install Ruby using Rbenv. You're ready to install the Ruby gems for Rideshare.\n\nRun the following command from the Rideshare directory:\n\n```sh\nbundle install\n```\n\n## Rideshare Development Database\n⚠️  This scripts expects PostgreSQL version 16. If you see syntax errors with underscore numbers like `10_000`, it's probably from using an older version that doesn't support that number style.\n\n⚠️   Normally in Ruby on Rails applications, you'd run `bin/rails db:create` to create the development and test databases. Don't do that here. Rideshare uses a custom script.\n\nThe script is called [`db/setup.sh`](db/setup.sh). Don't run it yet. The video below shows common issues for this section.\n\n\u003cdetails\u003e\n\u003csummary\u003e🎥 Rideshare DB setup. Common issues running db/setup.sh\u003c/summary\u003e\n\u003ca href=\"https://www.loom.com/share/fc919520089c4e0abb2c0a02b68bbd91\"\u003e\n  \u003cimg style=\"max-width:300px;\" src=\"https://cdn.loom.com/sessions/thumbnails/fc919520089c4e0abb2c0a02b68bbd91-with-play.gif\"\u003e\n\u003c/a\u003e\n\u003c/div\u003e\n\u003c/details\u003e\n\nBefore you run it, let's set some environment variables. Open the file `db/setup.sh` and read the comments at the top for more info about these env vars:\n\n- `RIDESHARE_DB_PASSWORD`\n- `DB_URL`\n\n⚠️  The script generates a password value using `openssl`, assuming it's installed and available.\n\nOnce you've set values, before running the script, run `echo $RIDESHARE_DB_PASSWORD` (and `echo $DB_URL`) to make sure they're set.\n\nOnce both are set, you're ready to run the script.\n\nLet's capture the output of the script. Use the command below to do that. The script output goes into `output.log` file so we can more easily review it for errors.\n\n```sh\nsh db/setup.sh 2\u003e\u00261 | tee -a output.log\n```\n\nSince you set `RIDESHARE_DB_PASSWORD` earlier, create or update the special `~/.pgpass` file with the password you generated.\nThis allows us to put the PostgreSQL user in the connection string, without needing to also supply the password.\n\nRefer to `postgresql/.pgpass.sample` for an example, and copy the example into your own `~/.pgpass` file, replacing the password with your generated one.\n\nWhen you've updated `~/.pgpass`, it should look like the line below. The last segment (`2C6uw3LprgUMwSLQ` below) is the password you generated.\n\n```sh\nlocalhost:5432:rideshare_development:owner:2C6uw3LprgUMwSLQ\n```\n\nRun `chmod 0600 ~/.pgpass` to change the file mode (permissions).\n\nFinally, run `export DATABASE_URL=\u003cvalue from .env\u003e`, getting the value from the `.env` file in this project, set as the value of the `DATABASE_URL` environment variable.\n\nConfirm that's a non-empty value by running `echo $DATABASE_URL`.\n\nOnce `DATABASE_URL` is set, we'll use it as an argument to `psql` to connect to the database. Run `psql $DATABASE_URL` to do that.\n\nOnce connected, you're good to go. If you'd like to do more checks, expand the checks and run through them below.\n\n\u003cdetails open\u003e\n\n\u003csummary\u003eInstallation Checks\u003c/summary\u003e\n\nFrom within psql, run this:\n\n```sql\nSELECT current_user;\n```\n\nConfirm user `owner` is displayed.\n\n```sql\nowner@localhost:5432 rideshare_development# select current_user;\n current_user\n --------------\n  owner\n```\n\nFrom psql, run the *describe namespace* meta-command:\n\n```sql\n\\dn\n```\n\nVerify the `rideshare` schema is displayed.\n\n```sql\nowner@localhost:5432 rideshare_development# \\dn\n  List of schemas\n   Name    | Owner\n-----------+-------\n rideshare | owner\n```\n\nNow that you've confirmed the `owner` user and the `rideshare` schema have been set up correctly, you can run the migrations to create Rideshare's tables.\n\u003c/details\u003e\n\n\n## Run Migrations\nRun migrations the standard way:\n\n```sh\nbin/rails db:migrate\n```\n\nRun the *describe table* meta command next: `\\dt`. Rideshare tables like `users`, `trips` are listed.\n\nNote that migrations are preceded by the command `SET role = owner`, so they're run with `owner` as the owner of database objects.\n\nSee `lib/tasks/migration_hooks.rake` for more details.\n\nIf migrations ran successfully, you're good to go!\n\n## Data Loads\nTo load some sample data, check out: [db/README.md](db/README.md)\n\n\n# Development Guides and Documentation\n\n## Troubleshooting\nThe Rideshare repository has many `README.md` files within subdirectories. Run `find . -name 'README.md'` to see them all.\n\n- For expanded installation and troubleshooting, visit: [Development Guides](https://github.com/andyatkinson/development_guides)\n- For DB things: [db/README.md](db/README.md)\n- For database scripts: [db/scripts/README.md](db/scripts/README.md)\n- For PostgreSQL things: [postgresql/README.md](postgresql/README.md)\n- For Docker things: [docker/README.md](docker/README.md)\n- For DB scrubbing: [db/scrubbing/README.md](db/scrubbing/README.md)\n- For test environment details in Rideshare, check out: [TESTING.md](TESTING.md)\n- For Guides and Tasks in this repo, check out: [Guides](GUIDES.md)\n\n# User Interfaces\nAlthough Rideshare is an *API-only* app, there are some UI elements.\n\nRideshare runs [PgHero](https://github.com/ankane/pghero) which has a UI.\n\nConnect to it:\n\n```sh\nbin/rails server\n```\n\nOnce that's running, visit \u003chttp://localhost:3000/pghero\u003e in your browser to see it.\n\n![Screenshot of PgHero for Rideshare](https://i.imgur.com/VduvxSK.png)\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyatkinson%2Frideshare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyatkinson%2Frideshare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyatkinson%2Frideshare/lists"}