Comments (3)
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.
Seconded. Your work is amazing.
from tern.
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)
- Error initializing migrator: ERROR: prepared statement already exists (SQLSTATE 42P05) HOT 5
- port ignored in tern.conf HOT 8
- Add migrations path to config HOT 5
- New release with version using pgx v5? HOT 11
- Purpose of MigratorOptions.FileSystem (v2-dev) HOT 3
- Pre-built binaries HOT 1
- How to load .env file variables in tern.config HOT 1
- Dependency-based or git-based conflict resolution HOT 2
- ssh-tunnel port not being respected from config HOT 1
- Migrating from another migration tool HOT 2
- Ability to mask created user's passwords HOT 1
- runtime error: invalid memory address or nil pointer dereference HOT 2
- Do not use a schema for expressing the schema version table HOT 7
- Need V2 release with gengen feature HOT 1
- Automatic migrations in case of outdated version found in migration_scheme. HOT 1
- How to disable template engine? HOT 1
- rollback using helm ends with an error if "last" is used HOT 1
- Inject custom data when creating a `NewMigrator` HOT 2
- [question] migration multiples schemas HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tern.