Skip to content

Commit

Permalink
Update postgres.md
Browse files Browse the repository at this point in the history
Added additional setup information for PostgreSQL.
  • Loading branch information
Dartanlla committed May 27, 2024
1 parent 4bdd41b commit d2cc2e4
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions docs/getting-started/database-setup/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,38 @@ nav_order: 1

[PostgreSQL](https://www.postgresql.org/) is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

## Using Postgres as an alternative to MSSQL
1. Open `src/.env.`
2. Replace the `OWSDBConnectionString` with `Host=host.docker.internal;Port=5432;Database=openworldserver;Username=postgres;Password=yourStrong(!)Password;`
3. Replace the value in **OWSDBBackend** with **postgres**
## PostgreSQL is the now the default database technology for OWS
No configuration changes are required to use PostgreSQL

## Update database version
All database updates are applied by default now. If you need to update an existing database, the update scripts are in the ./Databases/Postgres/UpdateScripts folder.

1. Open PGAdmin3/4 and connect to localhost using the following credentials:

<dl>
<dt>Username</dt>
<dd>postgres</dd>
<dt>Password</dt>
<dd>yourStrong(!)Password</dd>
</dl>

2. Run the following SQL statement against the Open World Server database.

```sql
SELECT * FROM OWSVersion
```

3. Compare the **OWSDBVersion** returned with the SQL update scripts in the `Databases\MSSQL\UpdateScriptsFolder` to see which scripts to run on your database.

4. The update scripts have **From[SomeVersion]To[SomeVersion]** in the name. Run them in order starting with the **From[SomeVersion]** that matches your **OWSDBVersion** from the previous step. To run the script open the file, copy the contents from it and run it as a SQL statement against the Open World Server database like you did in step 2. If you are not familiar with SQL please refer to the [SQL Tutorial](https://www.w3schools.com/sql/) to learn more about it.
## Warning! If you already have PostgreSQL installed on your development PC running on port 5432, then OWS 2 will not work
Please adjust the OWS 2 configuration to run PostgreSQL on an alternate port. Here is an example of what to change to switch OWS copy of PostgreSQL to port 15432:
1. Open the .env file and go to the Postgres connection string and edit it like this:
```
# Postgres
DATABASE_CONNECTION_STRING="Host=host.docker.internal;Port=15432;Database=openworldserver;Username=postgres;Password=${DATABASE_PASSWORD};"
```
2. Open databases.yml and edit it like this:
```
### PostgreSQL Database
postgres:
build:
context: postgres/
environment:
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
ports:
- "15432:5432"
volumes:
- database:/var/lib/postgresql/data
container_name: PostgreSQL
```
Notice that we ONLY change the first number to 15432 and not the second number. The second number has to stay 5432.

## Create API Key

1. Open PGAdmin3/4 and connect to localhost using the following credentials:
1. Open PGAdmin3/4 or dBeaver and connect to localhost using the following credentials:

<dl>
<dt>Username</dt>
Expand Down Expand Up @@ -75,5 +78,7 @@ nav_order: 1
```sql
SELECT CustomerGUID FROM Customers LIMIT 1;
```
The above query only works if this is a new OWS 2 installation. A common issue during setup is when you have more than one API key (CustomerGUID).


[Next: OWS Starter Project](starter-project){: .btn .btn-outline }
[Next: OWS Starter Project](starter-project){: .btn .btn-outline }

0 comments on commit d2cc2e4

Please sign in to comment.