OpenFn / OpenFn/apollo

Add inserted_at to lightning_columns

Open Beginner friendly
#559 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

platform
Dominant language
Jupyter Notebook
Stars
5
Forks
10
Avg merge
2d 20h
Merged PRs (30d)
17

Description

Summary

lightning_clients doesn't record when a client was provisioned, so we can't tell when a client was added, and a future client list command would have nothing to sort or display by.

The runner records each applied filename in _migrations and only runs files it hasn't recorded yet (platform/src/db/migrate.ts:40-45); that table is the source of truth, not the IF NOT EXISTS guards in the DDL (platform/src/db/migrate.ts:5-7).

Proposed change
  • Add platform/migrations/0002_lightning_clients_inserted_at.sql with:
    ALTER TABLE lightning_clients
      ADD COLUMN IF NOT EXISTS inserted_at TIMESTAMPTZ NOT NULL DEFAULT now();
    
    Existing rows backfill to the migration time, which is fine for a provisioning timestamp.
  • No change needed in store.ts: insertClient names its columns explicitly (name, auth_token_hash, anthropic_api_key), and DEFAULT now() fills in inserted_at on insert (platform/src/auth/client/store.ts:34-37). Verified.
  • Extend the column assertions in db.test.ts to expect inserted_at (platform/test/db.test.ts:36-39).
Acceptance criteria
  • platform/migrations/0002_lightning_clients_inserted_at.sql adds inserted_at TIMESTAMPTZ NOT NULL DEFAULT now() via ALTER TABLE ... ADD COLUMN IF NOT EXISTS
  • 0001_lightning_clients.sql is left untouched
  • bun run migrate applies 0002 against a DB that already has 0001 recorded, and is a no-op on a second run (platform/src/db/migrate.ts:42-47)
  • Existing rows have inserted_at backfilled to the migration time
  • db.test.ts asserts inserted_at is present in lightning_clients (platform/test/db.test.ts:36-39)
  • No change required to insertClient in store.ts (confirmed the default populates it)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with platform/src/db/migrate.ts:40-47 and platform/test/db.test.ts:36-39, then inspect the existing migration format in platform/migrations/0001_lightning_clients.sql. Run bun run migrate against a database with 0001 recorded and execute the database tests. Done means 0002 applies once, existing rows receive inserted_at, and the column assertion passes without changes to store.ts.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, sql, typescript
Domain
database, testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.