Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ specs:
AWS_SECRET_ACCESS_KEY: test
CAPYBARA_WAIT_TIME_SECONDS: 5
COVERAGE: 'true'
DOCKER_DB_HOST: postgres
DOCKER_DB_HOST: db-postgres
POSTGRES_DB: identity_idp_test
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_password
POSTGRES_HOST_AUTH_METHOD: trust
RAILS_ENV: test
services:
- name: postgres:13.9
- name: postgis/postgis:13-3.3
alias: db-postgres
command: ["--fsync=false", "--synchronous_commit=false", "--full_page_writes=false"]
command: ['--fsync=false', '--synchronous_commit=false', '--full_page_writes=false']
- name: redis:7.0
alias: db-redis
artifacts:
Expand Down Expand Up @@ -258,4 +258,3 @@ trigger_devops:
include:
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.yml

1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
brew 'postgresql@14'
brew 'postgis'
brew 'redis'
brew 'node@16'
brew 'yarn'
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ruby "~> #{File.read(File.join(__dir__, '.ruby-version')).strip}"

gem 'rails', '~> 7.0.0'

gem 'activerecord-postgis-adapter'
gem 'ahoy_matey', '~> 3.0'
gem 'aws-sdk-kms', '~> 1.4'
gem 'aws-sdk-pinpoint'
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ GEM
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activerecord-postgis-adapter (8.0.2)
activerecord (~> 7.0.0)
rgeo-activerecord (~> 7.0.0)
activestorage (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
Expand Down Expand Up @@ -550,6 +553,10 @@ GEM
railties (>= 5.0)
retries (0.0.5)
rexml (3.2.5)
rgeo (3.0.0)
rgeo-activerecord (7.0.1)
activerecord (>= 5.0)
rgeo (>= 1.0.0)
rotp (6.2.0)
rouge (4.1.1)
rqrcode (2.1.0)
Expand Down Expand Up @@ -722,6 +729,7 @@ PLATFORMS
ruby

DEPENDENCIES
activerecord-postgis-adapter
ahoy_matey (~> 3.0)
aws-sdk-cloudwatchlogs
aws-sdk-kms (~> 1.4)
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
postgresql: &postgresql
adapter: postgresql
adapter: postgis
encoding: utf8
database: identity_idp_<%= Rails.env %>
port: 5432
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPostgisExtensionToDatabase < ActiveRecord::Migration[7.0]
def change
enable_extension 'postgis'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity / learning, what drove you to check that? A possible error if it's already installed and we try to re-install it?

Copy link
Contributor

@mitchellhenke mitchellhenke Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly. If for some reason the extension was already created, a "CREATE EXTENSION" without "IF NOT EXISTS" would raise an error. Mostly driven by past experiences in hand-writing migrations poorly 😀

end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
enable_extension "pg_stat_statements"
enable_extension "pgcrypto"
enable_extension "plpgsql"
enable_extension "postgis"

create_table "account_reset_requests", force: :cascade do |t|
t.integer "user_id", null: false
Expand Down
2 changes: 2 additions & 0 deletions docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ If not using macOS:
- [rbenv](https://github.com/rbenv/rbenv) (lets you install and switch between different versions of Ruby)
- Ruby. Choose the version [in the `.ruby-version` file](../.ruby-version)
- [PostgreSQL](http://www.postgresql.org/download/)
- [PostGIS](https://postgis.net/documentation/getting_started/#installing-postgis)
- Note: if you run into errors installing `postgis` or creating the databse, check [the troubleshooting docs](./troubleshooting.md#errors-related-to-the-databse).
- [Redis 7+](http://redis.io/)
- [Node.js v16](https://nodejs.org)
- [Yarn](https://yarnpkg.com/en/)
Expand Down
24 changes: 24 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ $ bundle install
$ yarn install
```

### Errors related to the database

One error you might see is:

```
Caused by:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR: extension "postgis" is not available
DETAIL: Could not open extension control file "/opt/homebrew/opt/postgresql@15/share/postgresql@15/extension/postgis.control": No such file or directory.
HINT: The extension must first be installed on the system where PostgreSQL is running.
```

If you see the above message:

- double check that `postgis` is installed with `brew list`
- if `postgis` is listed, it means when you brew installed you might have installed `postgis` in a different postgresql db than the app is using
- in this case, look at `brew list` again, and remove any `postgres` db that is not listed in [the Brewfile](../Brewfile) (`brew uninstall __`)
- if you try to run the migration now you might get a:
```
connection to server at "::1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
```
- this likely means postgres is no longer running
- try `brew services start postgresql@14` (or your version) and then re-run the migration

## I am receiving errors when creating the development and test databases

If you receive the following error (where _whoami_ == _your username_):
Expand Down