Skip to content

Commit e458dbf

Browse files
committed
refactor(env)!: rename database configuration environment variables
BREAKING CHANGE: Migrate from legacy `HTM_DB*` format to new `HTM_DATABASE__*` namespaced variables for improved clarity and consistency
1 parent 474c2fa commit e458dbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+308
-357
lines changed

.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ We will use **PostgreSQL with TimescaleDB** as the primary storage backend for H
115115
### Connection Configuration
116116
```ruby
117117
# Via environment variable (preferred)
118-
ENV['HTM_DBURL'] = "postgresql://user:pass@host:port/dbname?sslmode=require"
118+
ENV['HTM_DATABASE__URL'] = "postgresql://user:pass@host:port/dbname?sslmode=require"
119119

120120
# Parsed into connection hash
121121
{

.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ LIMIT $3;
284284
ruby enable_extensions.rb
285285

286286
# 2. Run database schema with triggers
287-
psql $HTM_DBURL < sql/schema.sql
287+
psql $HTM_DATABASE__URL < sql/schema.sql
288288

289289
# 3. Use HTM normally - embeddings automatic!
290290
ruby -r ./lib/htm -e "HTM.new(robot_name: 'Bot').add_node('test', 'value')"
@@ -294,16 +294,16 @@ ruby -r ./lib/htm -e "HTM.new(robot_name: 'Bot').add_node('test', 'value')"
294294

295295
```bash
296296
# 1. Backup database
297-
pg_dump $HTM_DBURL > htm_backup.sql
297+
pg_dump $HTM_DATABASE__URL > htm_backup.sql
298298

299299
# 2. Enable pgai extension
300300
ruby enable_extensions.rb
301301

302302
# 3. Apply new schema (adds triggers)
303-
psql $HTM_DBURL < sql/schema.sql
303+
psql $HTM_DATABASE__URL < sql/schema.sql
304304

305305
# 4. (Optional) Regenerate embeddings with new model
306-
psql $HTM_DBURL -c "UPDATE nodes SET value = value;"
306+
psql $HTM_DATABASE__URL -c "UPDATE nodes SET value = value;"
307307
# This triggers embedding regeneration for all nodes
308308
```
309309

.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ htm.add_node('memory_001', 'PostgreSQL with TimescaleDB handles time-series data
333333
HTM::Database.migrate
334334

335335
# 2. (Optional) Re-extract topics for existing nodes
336-
psql $HTM_DBURL -c "UPDATE nodes SET value = value;"
336+
psql $HTM_DATABASE__URL -c "UPDATE nodes SET value = value;"
337337
# Triggers topic extraction for all existing nodes
338338
```
339339

.envrc

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,22 @@
22

33
export RR=`pwd`
44

5-
export RAILS_ENV=development
5+
export HTM_ENV=development
66
export HTM_EXTRACT_PROPOSITIONS=true
77

88
# Database connection - Localhost PostgreSQL
9-
export HTM_DBHOST=localhost
10-
export HTM_DBPORT=5432
11-
export HTM_DBNAME=htm_development
12-
export HTM_DBUSER=${USER}
13-
export HTM_DBPASS=
14-
export HTM_DBURL="postgresql://${HTM_DBUSER}@${HTM_DBHOST}:${HTM_DBPORT}/${HTM_DBNAME}?sslmode=disable"
15-
# export HTM_DBURL="postgresql://dewayne@localhost:5432/htm_development"
16-
17-
# Uncomment if using TimescaleDB Cloud instead:
18-
# export HTM_SERVICE_NAME=$TIGER_SERVICE_NAME
19-
# export HTM_DBURL=$TIGER_DBURL
20-
# export HTM_DBNAME=$TIGER_DBNAME
21-
# export HTM_DBUSER=$TIGER_DBUSER
22-
# export HTM_DBPASS=$TIGER_DBPASS
23-
# export HTM_DBHOST=$TIGER_DBHOST
24-
# export HTM_DBPORT=$TIGER_DBPORT
9+
export HTM_DATABASE__HOST=localhost
10+
export HTM_DATABASE__PORT=5432
11+
export HTM_DATABASE__NAME=htm_development
12+
export HTM_DATABASE__USER=${USER}
13+
export HTM_DATABASE__PASSWORD=
14+
export HTM_DATABASE__URL="postgresql://${HTM_DATABASE__USER}@${HTM_DATABASE__HOST}:${HTM_DATABASE__PORT}/${HTM_DATABASE__NAME}?sslmode=disable"
2515

2616
# Client-side embedding generation
27-
# HTM generates embeddings before inserting into database
28-
export HTM_EMBEDDINGS_PROVIDER=ollama
29-
export HTM_EMBEDDINGS_MODEL=embeddinggemma
30-
export HTM_EMBEDDINGS_BASE_URL=http://localhost:11434
31-
export HTM_EMBEDDINGS_DIMENSION=768
17+
export HTM_EMBEDDING__PROVIDER=ollama
18+
export HTM_EMBEDDING__MODEL=embeddinggemma
19+
export HTM_EMBEDDING__DIMENSIONS=768
3220

3321
# Topic extraction (client-side)
34-
export HTM_TOPIC_PROVIDER=ollama
35-
export HTM_TOPIC_MODEL=phi4
36-
export HTM_TOPIC_BASE_URL=http://localhost:11434
22+
export HTM_TAG__PROVIDER=ollama
23+
export HTM_TAG__MODEL=phi4

.irbrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# HTM Interactive Development Console
4-
# Usage: HTM_DBURL="postgresql://user@localhost:5432/htm_development" irb
4+
# Usage: HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development" irb
55

66
require_relative 'lib/htm'
77
require 'debug_me'

.tbls.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# tbls configuration for HTM database documentation
22
# https://github.com/k1LoW/tbls
33

4-
# Database connection - uses HTM_DBURL environment variable
4+
# Database connection - uses HTM_DATABASE__URL environment variable
55
# tbls expands environment variables with $VAR or ${VAR} syntax
6-
dsn: $HTM_DBURL
6+
dsn: $HTM_DATABASE__URL
77

88
# Output documentation to docs/database directory
99
docPath: docs/database

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ HTM includes a Model Context Protocol server with 23 tools for memory management
3939
"mcpServers": {
4040
"htm": {
4141
"command": "htm_mcp",
42-
"env": { "HTM_DBURL": "postgresql://localhost/htm" }
42+
"env": { "HTM_DATABASE__URL": "postgresql://localhost/htm" }
4343
}
4444
}
4545
}

Rakefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ Rake::TestTask.new(:test) do |t|
1010
t.verbose = true
1111
end
1212

13-
# Ensure test task runs with RAILS_ENV=test
13+
# Ensure test task runs with HTM_ENV=test (takes priority over RAILS_ENV/RACK_ENV)
1414
task :test do
15-
ENV['RAILS_ENV'] = 'test'
15+
ENV['HTM_ENV'] = 'test'
1616
end
1717

1818
# Prepend environment setup before test runs
1919
Rake::Task[:test].enhance [:set_test_env]
2020

2121
task :set_test_env do
22-
ENV['RAILS_ENV'] = 'test'
22+
ENV['HTM_ENV'] = 'test'
23+
# Set database URL if not already configured
24+
# Uses current system user for local PostgreSQL connection
25+
unless ENV['HTM_DATABASE__URL']
26+
ENV['HTM_DATABASE__URL'] = "postgresql://#{ENV['USER']}@localhost:5432/htm_test"
27+
end
2328
end
2429

2530
task default: :test

config/database.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

db/seed_data/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ The seeding process uses environment variables for configuration. All settings h
2323

2424
### Database Settings
2525

26-
- `HTM_DBURL` - Full PostgreSQL connection URL (required)
27-
- Or individual settings: `HTM_DBHOST`, `HTM_DBPORT`, `HTM_DBNAME`, `HTM_DBUSER`, `HTM_DBPASS`
26+
- `HTM_DATABASE__URL` - Full PostgreSQL connection URL (required)
27+
- Or individual settings: `HTM_DATABASE__HOST`, `HTM_DATABASE__PORT`, `HTM_DATABASE__NAME`, `HTM_DATABASE__USER`, `HTM_DATABASE__PASSWORD`
2828

2929
### Other Settings
3030

0 commit comments

Comments
 (0)