Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Make usable from within node.js app #19

Closed
brandonros opened this issue Aug 4, 2020 · 2 comments
Closed

Make usable from within node.js app #19

brandonros opened this issue Aug 4, 2020 · 2 comments

Comments

@brandonros
Copy link

You'd get a ton of users if somehow it were possible to npm install some kind of wrapper around automigrate that node.js applications could require(), then execute the migration diffs at startup with.

Right now with knex migrations (nowhere near as good as this, I do:

const db = await initDb()
const schema = await readSchema()
await migrateDatabase(db, schema)

all from within the application (that is containerized, etc.)

having automigrate as an external tool in another language will make the Dockerfiles kind of ugly. I guess the node index.js entrypoint could be replaced with a script that runs automigrate before node index.js

might be a pain for people doing vault temporary credentials, etc.

@abe-winter
Copy link
Owner

hey brandon! thanks for checking out the repo.

I've gotten similar feedback in the past (rewrite in go so it can be distributed as a binary, for example). I think that automig doesn't have enough users right now to justify that amount of work.

You could, potentially, run automig update inside node exec if you have all the python deps in your container.

It sounds like you're running migrations every time an instance of the app starts up, rather than as a side effect of deploys?

I've used automig in a golang repo before -- there I had an entirely separate python Dockerfile that ran as part of deploys. I have an example Dockerfile in the repo, it might be kind of stale now though.

I haven't thought too much about automatic migrations because they can get complicated -- I read this benchling article from last year -- they have things like backwards compatibility checks and pre / post deploy steps depending on whether something is being added or removed.

@brandonros
Copy link
Author

okie dokie, as long as you are aware

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants