GithubHelp home page GithubHelp logo

Comments (3)

josharian avatar josharian commented on August 26, 2024 2

I presume that for this use case you are embedding tern rather than using the CLI?

Yep.

Ideally, you would want make it obvious that there was Go code attached to a migration.

True. Instead of pre/post, one (not great?) option here would be to put a magic comment in the migration, and then tie magic comments to registered functions.

This means it would be easy to inadvertently change the meaning of a migration.

It's true. What we have done in the past is address this through conventions, and then delete the Go half as soon as possible, leaving behind only comments.

Another approach might be to expose more of the connection control to the calling application. It could manage the transactions itself and call its own code whenever it wished.

I like it. More obvious that it is a footgun. :)


Not 100% related, but I'd like to say thank you. Maintaining OSS is a serious undertaking, and I really appreciate all your work. pgx (et al) is a real boon to the ecosystem, and we are indebted to you for it.

from tern.

davidmdm avatar davidmdm commented on August 26, 2024 1

Seconded. Your work is amazing.

from tern.

jackc avatar jackc commented on August 26, 2024

I can see this being useful. I presume that for this use case you are embedding tern rather than using the CLI?

From the tern side exposing a hook seems fairly simple, but getting the usability right might be a little tricky. Ideally, you would want make it obvious that there was Go code attached to a migration.

In addition, this might create a foot-gun regarding reproducible migrations. With SQL migration files it is well understood that they should be immutable once finalized / released / deployed. Arbitrary code could reach anywhere into your system. This means it would be easy to inadvertently change the meaning of a migration.

...

Another approach might be to expose more of the connection control to the calling application. It could manage the transactions itself and call its own code whenever it wished.


Regarding #47, it has the advantage of avoiding the risk of coupling to mutable application logic as well as being runnable from the CLI.

As far as https://github.com/mvdan/sh, I don't think that would be necessary. What I envision is tern literally creating a PostgreSQL proxy that relays commands to the PostgreSQL server and shelling out to the script with the PG* environment variables set to point to its proxy. tern wouldn't need to interpret the script.

from tern.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.