Skip to content

General feedbacks from first try of pgstrap #8

@Glinte

Description

@Glinte

There is no discussion page so I am hijacking a issue as discussion, sorry if you don't want noise or dont care about external users. Totally understandable if this is meant to be a personal/internal package.

  1. It doesn't work on windows
> db:generate
> pgstrap generate

cli.cjs generate

generate types and sql documentation from database

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --pglite                                            [boolean] [default: false]

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:209:11)
    at defaultLoad (node:internal/modules/esm/load:107:3)
    at ModuleLoader.load (node:internal/modules/esm/loader:800:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:580:43)
    at #createModuleJob (node:internal/modules/esm/loader:604:36)
    at #getJobFromResolveResult (node:internal/modules/esm/loader:338:34)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:306:41)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:643:25) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
  1. Your "Quick Start" section is a bit misleading, you mentioned changing pgstrap.config.js in "Usage" but not here, and running those commands without proper config seems to like it requires a local postgres instance, I was trying to generate a schema for a remote db.

  2. Speaking of remote database, there is no information about specifying the url. Looking at the source code it seems like you can only override it via an env var

pgstrap/src/generate.ts

Lines 64 to 68 in 3039eee

const port = (server.address() as any).port
const connectionString = `postgres://postgres:postgres@127.0.0.1:${port}/postgres`
const prevDbUrl = process.env.DATABASE_URL
process.env.DATABASE_URL = connectionString

I did manage to get it working at the end though, and I expect it to be a great help for feeding into LLM context, so thanks for the package regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions