[Ch 6] Database provisioning — CNPG for API tokens and sessions #16

Open
opened 2026-08-01 19:02:52 +00:00 by ldraney · 1 comment
Owner

Type

Feature

Lineage

Standalone — scoped from platform-playbook chapter 6 for the full-stack mdview vision.

Repo

ldraney/mdview, ldraney/pal-e-services

User Story

As a developer
I want mdview to have a database
So that it can store API tokens and user sessions for authenticated access

Context

mdview is currently stateless — no database, no models. The full-stack vision requires storing API tokens (so CLI users can authenticate) and user sessions (so web users can log in via Keycloak). This ticket provisions the database on CNPG and adds the pg gem to the app. The actual models come in Ch 11 (integration).

File Targets

  • Gemfile — add pg gem
  • config/database.yml — create, pointing to CNPG
  • pal-e-services/terraform/databases.tf — add mdview to service_databases

Files the agent should NOT touch:

  • app/controllers/markdown_controller.rb — no app logic changes in this ticket

Feature Flag

none

Acceptance Criteria

  • pg gem in Gemfile and bundle installs
  • config/database.yml exists with CNPG connection config
  • Terraform creates mdview role and mdview database on CNPG
  • rails db:prepare succeeds against CNPG

Test Expectations

  • No app-level tests needed — this is infra provisioning
  • Run command: tofu plan in pal-e-services shows database resources

Constraints

  • Follow existing service_databases pattern from landscaping-assistant
  • Database name: mdview, role name: mdview

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-mdview — project this affects
### Type Feature ### Lineage Standalone — scoped from platform-playbook chapter 6 for the full-stack mdview vision. ### Repo `ldraney/mdview`, `ldraney/pal-e-services` ### User Story As a developer I want mdview to have a database So that it can store API tokens and user sessions for authenticated access ### Context mdview is currently stateless — no database, no models. The full-stack vision requires storing API tokens (so CLI users can authenticate) and user sessions (so web users can log in via Keycloak). This ticket provisions the database on CNPG and adds the pg gem to the app. The actual models come in Ch 11 (integration). ### File Targets - `Gemfile` — add `pg` gem - `config/database.yml` — create, pointing to CNPG - `pal-e-services/terraform/databases.tf` — add mdview to `service_databases` Files the agent should NOT touch: - `app/controllers/markdown_controller.rb` — no app logic changes in this ticket ### Feature Flag none ### Acceptance Criteria - [ ] `pg` gem in Gemfile and bundle installs - [ ] `config/database.yml` exists with CNPG connection config - [ ] Terraform creates `mdview` role and `mdview` database on CNPG - [ ] `rails db:prepare` succeeds against CNPG ### Test Expectations - [ ] No app-level tests needed — this is infra provisioning - Run command: `tofu plan` in pal-e-services shows database resources ### Constraints - Follow existing `service_databases` pattern from landscaping-assistant - Database name: `mdview`, role name: `mdview` ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-mdview` — project this affects
Author
Owner

Scope Review: NEEDS_REFINEMENT

Review note: review-1947-2026-08-01
Template complete, traceability partial -- arch note arch-mdview-infra missing, file targets have errors.

  • [SCOPE] Create architecture note arch-mdview-infra (404 in pal-e-docs)
  • [BODY] Wrong file target: databases.tf is the module code (for_each loop); the service_databases entry goes in k3s.tfvars
  • [BODY] Missing file target: Dockerfile needs libpq-dev (build) and libpq5 (runtime) for pg gem native extension
  • [BODY] Wrong constraint reference: landscaping-assistant has no service_databases entry; correct reference is prediction-assistant
  • [BODY] AC "rails db:prepare succeeds against CNPG" needs test method clarified -- current k8s deployment is an nginx proxy, not Rails
## Scope Review: NEEDS_REFINEMENT Review note: `review-1947-2026-08-01` Template complete, traceability partial -- arch note arch-mdview-infra missing, file targets have errors. - **[SCOPE]** Create architecture note `arch-mdview-infra` (404 in pal-e-docs) - **[BODY]** Wrong file target: `databases.tf` is the module code (for_each loop); the service_databases entry goes in `k3s.tfvars` - **[BODY]** Missing file target: `Dockerfile` needs `libpq-dev` (build) and `libpq5` (runtime) for pg gem native extension - **[BODY]** Wrong constraint reference: landscaping-assistant has no service_databases entry; correct reference is prediction-assistant - **[BODY]** AC "rails db:prepare succeeds against CNPG" needs test method clarified -- current k8s deployment is an nginx proxy, not Rails
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/mdview#16
No description provided.