-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Db based migration state persistence. #67
Conversation
A Store persists of file name, direction & time - each execution is persisted
Inspired from & supersedes #58 |
Example of a dbStore
|
Very cool! What do you think about making each adapter (except file-store) a separate module? That way we don't have to ship with a mongo db dependency which will be installed for people using the file store. Passing in Also, I'm not sure about I also think that the configuration of store should be done programatically somehow, so that the user doesn't have to repeat the same options every time they run migrations. Any thoughts? |
|
Reusable tests change migration script
All right - did a changes to meet 1,2,3. Major changes for testing & the cli. Check it out and give me some feedback |
Hey, this looks interesting; any updates on the status of this PR? I'd be interested in adding a mysql adaptor to this. db-migrate is a little bloated and unclean for my purposes. |
I havent heard anything for linus. Please add a mysql adapter and list the link on this pr. |
@sloops77 - Here's my first crack at a mysql adapter: https://github.com/node-migrate/node-migrate-mysqlstore I generally followed the styling of your node-migrate-mongostore |
Hey, im on hols till thursday. Ill take a look then in all probability. Cheers for the help! |
Sorry for the delay on this, I've been mening to take a look and this and also implement a postgres store for a while now... Lets do this! I'll create a organisation for keeping all the stores in, how does that sound? I'll invite both of you straight away. I'm thinking we keep the main app under Also, how do you feel about using standard style as the code style? It's so easy to enforce and it removes discussions about the style... |
Cool, I moved the mysql store to the organization and updated with standardjs styling (locally; see below). edit - Looks like I lost permission to push to the repo when changing orgs :/. I think you can restore those permissions since you are the owner @LinusU; mind doing that when you get a chance? |
Should be fixed now, all members should be able to edit all repos now |
I've actually been thinking a lot on how to make the very best migration framework, and finally took the time to clean up and commit some of my notes. This is not much at all, and I'm not saying that it's the way to do it, but I think that you might get some cool ideas from it. This have been my thoughts on what should be node-migrate 2.0, and I hope that I can commit the readme soon and not just engine documentation. Again, nothing is set in stone, these are just my personal thoughts on how it could be. https://github.com/LinusU/node-migrate/blob/next-gen-migrate/engine.md |
Added documentation for core, cli, and migrations: https://github.com/LinusU/node-migrate/tree/next-gen-migrate @joaosa that's a cool idea, I've never used it myself but that could probably be useful. I think it doesn't even need any extra implementation in the engine, we can just check if there is a |
Feels very rdbms oriented and not so applicable for nosql stores like mongo Cheers On Tue, 11 Oct 2016 at 10:14, Linus Unnebäck notifications@github.com
|
Yes, that might be true, I'm 100% committed to keeping migrate an "Abstract migration framework for node". Let's not make it rdbms specific! |
I think the engine should just expose a "connection" via a getConnection function that is passed to the migrations up/down functions |
Looks great! Another option is just not exposing the view/modify functions. The core philosophy of this module seems to be that it only tracks state, and has zero opinions about how the user changes state inside of migrations. Seems like view/modify are just optional features that would save the user from having to import/configure mysql/postgres/mongo inside of each feature since they are most-likely tracking the migrations in the same store they are modifying. Maybe don't make it a core feature, but let some engines expose utility methods like that which users could take advantage of optionally (i.e. the mongo/mysql engines could expose a getConnection method per @sloops77's suggestion)? For dry-run, you could just print the migration titles that would be run; that way it's just exposing the current state of the system and doesn't make any assumptions about the user's implementation (i.e. that there even IS a query to format). |
@LinusU @sloops77 Indeed sqitch is oriented towards RDBMSs and it wouldn't be aligned with an abstract migration framework. Following its structure/conventions wasn't my point. My suggestion was more in the lines of burrowing one idea from it, i.e.: "The idea is simply to test that a deploy script did what it was supposed to do. Such a test should make no assumptions about data or state other than that affected by the deploy script, so that it can be run against a production database without doing any damage. If it finds that the deploy script failed, it should die." (source) I find that often in live stage/production systems, the expectation that all migrations ran in succession and that state wasn't tampered with can sometimes be no more than an assumption. It is useful to be able to check if a particular DB change was indeed applied. E.g.:
Either way, feel free to take my suggestion or focus on other more pragmatic design aspects :) |
The original feature added here should now be implemented in #77. I know this has been pending for a long time, but @sloops77, if you could take a look at the readme to see if this satisfies your needs that would be awesome. The implementation is basically taken from this PR, just updated for all the other changes I made in the fork I had. If you are satisfied, feel free to close this. |
Closing from inactivity |
A Store persists of file name, direction & time - each execution is persisted