Skip to content

Commit 0f78fd8

Browse files
committed
V1.0.2, fixes Postgres setup script, updates docs (#41)
1 parent 37b834d commit 0f78fd8

File tree

5 files changed

+58
-11
lines changed

5 files changed

+58
-11
lines changed

.github/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ The db used will depend on which env vars are set.
275275

276276
- **Supabase**: Follow the Supabase [self-hosting docs](https://supabase.com/docs/guides/self-hosting), then use [dl-sb-iac](https://github.com/lissy93/dl-sb-iac) to import the schema and configure auth, edge functions, emails, etc.
277277
- Then set: `SUPABASE_URL` and `SUPABASE_ANON_KEY` environmental variables
278-
- **Postgres**: Deploy a Postgres instance, then use our [`setup-postgres.sh`](https://github.com/Lissy93/domain-locker/blob/main/db/setup-postgres.sh) script to init your DB with our[`schema.sql`](https://github.com/Lissy93/domain-locker/blob/main/db/schema.sql)
278+
- **Postgres**: Deploy a Postgres instance, then apply the [`schema.sql`](https://github.com/Lissy93/domain-locker/blob/main/db/schema.sql)
279+
- If DB already exists: `psql -h $DL_PG_HOST -U $DL_PG_USER -d $DL_PG_NAME -f ./db/schema.sql`
280+
- If creating from scratch: Use [`setup-postgres.sh`](https://github.com/Lissy93/domain-locker/blob/main/db/setup-postgres.sh) (requires superuser access)
279281
- Then set: `DL_PG_HOST`, `DL_PG_PORT`, `DL_PG_USER`, `DL_PG_PASSWORD`, `DL_PG_NAME`
280282

281283
```mermaid

db/setup-postgres.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ set -e
77
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
88

99
# Configuration variables: Use environment variables if set, otherwise use defaults
10-
DB_NAME="${DOMAIN_LOCKER_DB_NAME:-domain_locker}"
11-
DB_USER="${DOMAIN_LOCKER_DB_USER:-postgres}"
12-
DB_PASSWORD="${DOMAIN_LOCKER_DB_PASSWORD:-changeme2420}"
13-
DB_HOST="${DOMAIN_LOCKER_DB_HOST:-localhost}"
14-
DB_PORT="${DOMAIN_LOCKER_DB_PORT:-5432}"
10+
DB_NAME="${DL_PG_NAME:-domain_locker}"
11+
DB_USER="${DL_PG_USER:-postgres}"
12+
DB_PASSWORD="${DL_PG_PASSWORD:-changeme2420}"
13+
DB_HOST="${DL_PG_HOST:-localhost}"
14+
DB_PORT="${DL_PG_PORT:-5432}"
1515
# By default, assume schema.sql is in the same directory as this script
1616
SCHEMA_FILE="${SCHEMA_FILE:-$SCRIPT_DIR/schema.sql}"
1717

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "domain-locker",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"type": "module",
55
"engines": {
66
"node": ">=20.0.0"

src/content/docs/developing.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ Alternatively, you can deploy your own database, either a (self-hosted or Pro) S
3333

3434
### Option 1) Postgres
3535

36-
With Postgres, follow the setup instructions in [Postgres Setup](/about/developing/postgres-setup),
37-
then init the schema and start the DB with `./db/setup-postgres.sh`
38-
(to import the [`schema.sql`](https://github.com/Lissy93/domain-locker/blob/main/db/schema.sql)).
36+
With Postgres, follow the setup instructions in [Postgres Setup](/about/developing/postgres-setup).
37+
38+
If your database and user are already created, apply the schema directly:
39+
```bash
40+
psql -h $DL_PG_HOST -U $DL_PG_USER -d $DL_PG_NAME -f ./db/schema.sql
41+
```
42+
43+
Or if creating from scratch, use `./db/setup-postgres.sh` (requires superuser access) to import the [`schema.sql`](https://github.com/Lissy93/domain-locker/blob/main/db/schema.sql).
44+
3945
You'll then just need to pass the following env vars to the app, so it can connect to your Postgres instance.
4046

4147
```

src/content/docs/developing/postgres-setup.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,46 @@ In each case, you’d retrieve the connection details (hostname, port, credentia
5757

5858
## Configuring the Schema
5959

60-
We've got a Bash script in [`./db/setup-postgres.sh`](https://github.com/Lissy93/domain-locker/blob/main/db/setup-postgres.sh) which will take care of creating your database and applying the Domain Locker schema.
60+
### Quick Setup (Database Already Created)
61+
62+
If your database and user are already created (e.g., using Docker, Proxmox, or managed hosting), simply apply the schema:
63+
64+
```bash
65+
# Set your connection details
66+
export DL_PG_HOST=localhost
67+
export DL_PG_PORT=5432
68+
export DL_PG_USER=domainlocker
69+
export DL_PG_PASSWORD=your_password
70+
export DL_PG_NAME=domainlocker
71+
72+
# Apply schema directly
73+
PGPASSWORD="$DL_PG_PASSWORD" psql \
74+
-h "$DL_PG_HOST" \
75+
-p "$DL_PG_PORT" \
76+
-U "$DL_PG_USER" \
77+
-d "$DL_PG_NAME" \
78+
-f ./db/schema.sql
79+
```
80+
81+
### Full Setup (Create Database + Apply Schema)
82+
83+
If you need to create the database and user from scratch, use our setup script:
84+
85+
```bash
86+
# Set your connection details
87+
export DL_PG_HOST=localhost
88+
export DL_PG_PORT=5432
89+
export DL_PG_USER=domainlocker
90+
export DL_PG_PASSWORD=your_password
91+
export DL_PG_NAME=domainlocker
92+
93+
# Run the setup script (requires postgres superuser access)
94+
./db/setup-postgres.sh
95+
```
96+
97+
The [`setup-postgres.sh`](https://github.com/Lissy93/domain-locker/blob/main/db/setup-postgres.sh) script will create the database, user, grant privileges, and apply the schema.
98+
99+
**Note**: The setup script connects as the `postgres` superuser to create resources. If you don't have superuser access or the database is already created, use the Quick Setup method above.
61100

62101
---
63102

0 commit comments

Comments
 (0)