Live data from Hacker News

A Language Server for Postgres

github.com

11–20 of 24 posts

Re: A Language Server for Postgres

#12
post #8

Earlier quoted context omitted.

Similar. But this looks like it requires generating explicit migrations. The equivalent would be if every time you wanted to make a change to your terraform, you had to plan and save the generated plan file to your repository. Still not quite the right workflow IMO. I think TF nails it and that SQL things are held back by legacy thinking in the space.

From their docs [1] it seems that they support a workflow similar to Terraform. [1]: https://atlasgo.io/declarative/apply

Ahh, so they do! Their quick start link took me to their "versioned" workflow which is...basically the same thing any of a dozen tools has done for decades. Strange landing page choice to funnel into your market equivalence rather than differentiator.

Re: A Language Server for Postgres

#13
As someone who’s written a ton of PL/pgSQL code recently, I have been saving all my functions and their subsequent revisions in database migration files (Supabase). This feels like such a huge step backwards compared to browsing a well structured codebase with namespaces and modules. I know that Postgres provides schemas, and I am using them to a limited extent, but I am really speaking towards just having a tree oriented set of files on disk like I would with TypeScript, Golang, etc… and a way to refresh this tree against what’s currently active in my database. Had anyone else had a similar issue or better still, resolved it?

Re: A Language Server for Postgres

#14

As someone who’s written a ton of PL/pgSQL code recently, I have been saving all my functions and their subsequent revisions in database migration files (Supabase). This feels like such a huge step backwards compared to browsing a well structured codebase with namespaces and modules. I know that Postgres provides schemas, and I am using them to a limited extent, but I am really speaking towards just having a tree ori…

Declarative tools/workflows solve this much more elegantly than imperative migration tools. There's some initial discussion in sibling comment thread here, although that isn't specific to procedures/functions.

Regarding stored procs/funcs in particular and managing them like a codebase using a declarative tool, I have a blog post about this at https://www.skeema.io/blog/2023/10/24/stored-proc-deployment... – and although my product is specific to MySQL, a lot of the concepts in the first half of that post are generic and apply to any declarative tool. Some FOSS solutions to look into for Postgres include sqldef and Tusker.

Re: A Language Server for Postgres

#15

As someone who’s written a ton of PL/pgSQL code recently, I have been saving all my functions and their subsequent revisions in database migration files (Supabase). This feels like such a huge step backwards compared to browsing a well structured codebase with namespaces and modules. I know that Postgres provides schemas, and I am using them to a limited extent, but I am really speaking towards just having a tree ori…

Yeah, I’m in the midst of building out something for this. Involves a few pieces, the first is being able to apply the files in the right order https://github.com/joshainglis/topcat Essentially the output of that should be a file that should drop and recreate everything. Easy to build some automation around. And if you’re just operating on functions and views ect that should be all you need to allow a tree based code-base. If you also want to handle tables etc you’ll want to add a diffing tool (migra, atlas) etc.

Re: A Language Server for Postgres

#17
post #7

Would love to get this plugged into intellij/datagrip

I’ll second the confusion.

I’m interested in this for the opposite reason, jetbrains have fantastic sql support but I’d rather have a lang server that gives me a ‘good enough’ experience in the substantially faster vscode or zed.

Re: A Language Server for Postgres

#18

As someone who’s written a ton of PL/pgSQL code recently, I have been saving all my functions and their subsequent revisions in database migration files (Supabase). This feels like such a huge step backwards compared to browsing a well structured codebase with namespaces and modules. I know that Postgres provides schemas, and I am using them to a limited extent, but I am really speaking towards just having a tree ori…

pg-schema-diff from Stripe, although not sure whether it supports functions, but likely does.

Re: A Language Server for Postgres

#19

As someone who’s written a ton of PL/pgSQL code recently, I have been saving all my functions and their subsequent revisions in database migration files (Supabase). This feels like such a huge step backwards compared to browsing a well structured codebase with namespaces and modules. I know that Postgres provides schemas, and I am using them to a limited extent, but I am really speaking towards just having a tree ori…

https://github.com/t1mmen/srtd might help here. The general idea is to define functions/policies/etc as «SQL templates», your source of truth. The templates built into Supabase migrations.

While developing, srtd can hot/live reload your templates into the local db when changed.

I built this to scratch my own itch, and it’s been working VERY well for us. Huge DX benefits, and it’s made code reviews a LOT easier, since the reviewer can focus on what’s actually changed.

Re: A Language Server for Postgres

#20
post #19

As someone who’s written a ton of PL/pgSQL code recently, I have been saving all my functions and their subsequent revisions in database migration files (Supabase). This feels like such a huge step backwards compared to browsing a well structured codebase with namespaces and modules. I know that Postgres provides schemas, and I am using them to a limited extent, but I am really speaking towards just having a tree ori…

https://github.com/t1mmen/srtd might help here. The general idea is to define functions/policies/etc as «SQL templates», your source of truth. The templates built into Supabase migrations. While developing, srtd can hot/live reload your templates into the local db when changed. I built this to scratch my own itch, and it’s been working VERY well for us. Huge DX benefits, and it’s made code reviews a LOT easier, since…

This looks pretty damn good. Thank you!
Post reply on HN