question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`prisma pull` should add `///` comments based on postgres's `COMMENT`

See original GitHub issue

Problem

On Postgres database one can have COMMENT ON different database objects (tables, columns, types).

When generating prisma file from such database comments are written in the generated file. Tho doing so would be great!

Suggested solution

When generating prisma file look up object descriptions and use those as comments in generated prisma file.

Example

If your database dump looks like this:

CREATE TYPE foo AS ENUM('fiz', 'foz');
COMMENT ON TYPE foo IS 'foo comment';

CREATE TABLE IF NOT EXISTS bar
(
  id bigserial unique primary key,
  foo foo not null
);

COMMENT ON TABLE bar IS 'bar comment';
COMMENT ON COLUMN bar.id IS 'bar.id comment';

in a Postgres database, and then you run prisma pull, you shold get:

/// bar comment
model bar {
  /// bar.id comment
  id BigInt @id @default(autoincrement())
  foo foo
}

/// foo comment
enum foo {
  fiz
  foz
}

Related:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:18
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Jun 7, 2022

Not right now, now: https://pris.ly/roadmap But that does not mean it could be implemented soon - we are rather conservative how much we plan.

0reactions
janpiocommented, Aug 9, 2022

It is just a statement of a current fact: Prisma currently does not support reading or modifying the comments of tables and columns in databases, but we do support // and /// in the Prisma Schema file and use that data in different situations and locations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma schema (Reference)
A data source (PostgreSQL or MongoDB); A generator (Prisma Client) ... comment : These comments will show up in the abstract syntax tree...
Read more >
Prisma schema API (Reference)
API reference documentation for the Prisma Schema Language (PSL).
Read more >
PostgreSQL database connector (Reference) - Prisma
Prisma is based on the official PostgreSQL format for connection URLs, but does not support all arguments and includes additional arguments such as...
Read more >
Names in the underlying database - Prisma
With this modified model definition, Prisma automatically maps the Comment model to the comments table in the underlying database. Map field / column...
Read more >
Prisma Client API (Reference)
The Prisma Client API reference documentation is based on the following schema: ... Remarks. You must re-generate the Prisma Client each time you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found