Skip to content

Commit

Permalink
Merge pull request #88 from FRRouting/master
Browse files Browse the repository at this point in the history
Release 2.3.6
  • Loading branch information
RodrigoMNardi authored Aug 5, 2024
2 parents f4824cc + a3d9235 commit 1e77306
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,55 @@ In addition to the gems listed above, we need these to run the tests locally:
- ruby-rspec
- ruby-webmock

# Database Configuration

This document provides instructions on how to configure the database for the GitHub Hook Server project.

## Prerequisites

Ensure you have the following installed on your system:
- PostgreSQL (any version)

## Configuration Steps

1. **Install PostgreSQL**:
Follow the instructions for your operating system to install PostgreSQL. You can find the installation guide on the [official PostgreSQL website](https://www.postgresql.org/download/).

2. **Create a Database**:
After installing PostgreSQL, create a new database for the project. You can do this using the `psql` command-line tool or any PostgreSQL client.

```bash
RAKE_ENV=development psql -c "CREATE DATABASE github_hook_server_development;"
```
3. **Configure Database Connection**:
Update the `config/database.yml` file with the database connection details. You can use the following configuration as a template:

```yaml
development:
adapter: postgresql
encoding: unicode
database: github_hook_server_development
pool: 5
username: postgres
password: password
host: localhost
port: 5432
```
Replace the `username`, `password`, `host`, and `port` values with your PostgreSQL connection details.

4. **Run Database Migrations**:
After configuring the database, run the database migrations to set up the necessary tables and schema.
```bash
bundle exec rake db:migrate
```

5. **Verify the Configuration**:
Start the application and verify that it can connect to the database without any errors.
```bash
RAILS_ENV=development rackup -o 0.0.0.0 -p 9292 config.ru
```

# Usage

### Production
Expand Down
14 changes: 14 additions & 0 deletions database_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@
#
# frozen_string_literal: true

require 'active_record'
require 'otr-activerecord'

module OTR
module ActiveRecord
class << self
alias original_configure_from_file! configure_from_file!

def configure_from_file!(file)
config = YAML.safe_load_file(file, permitted_classes: [Symbol], aliases: true)
::ActiveRecord::Base.configurations = config
end
end
end
end

OTR::ActiveRecord.db_dir = 'db'
OTR::ActiveRecord.migrations_paths = ['db/migrate']
OTR::ActiveRecord.configure_from_file! 'config/database.yml'
Expand Down

0 comments on commit 1e77306

Please sign in to comment.