Open kael-shipman opened 6 years ago
I like it. :) This works nicely with your local config file patch.
The only concern I can think of is if some user has non-migration SQL under a migration directory. I think that is unlikely, so go for it. It looks like Posix find has -depth
but not -maxdepth
so that's a win.
My general concerns are backwards compatibility, trying to avoid config option explosion, continuing to remove bash-specific commands, and not breaking it.
Note: While the above commit works when versions are exclusively timestamps, it doesn't work when versions may match [0-9_.-]
, as in https://github.com/cfxmarkets/shmig/tree/human-timestamps.
The fix for this is simple: Instead of using -k+2n
in the sort command in pending_migrations
, use -k+2d
(or -k+2V
). This changes sorting from numeric (n
) to dictionary order (d
) or "version" order (V
).
(See complete merges at https://github.com/cfxmarkets/shmig/tree/cfx)
+1 for adding -R
option to relax max-depth
parameter in find_migrations
@srghma , I'm not sure what the status of PR #44 is, but what I understood from that discussion is what @mbucc had started to integrate the changes, but never did. I'm now maintaining a stable fork with this functionality at https://github.com/cfxmarkets/shmig if you'd like to use that. Documentation should be up to date on that.
@kael-shipman tnx, will check it
I agree this is a good feature. The TODO list is:
So it will come, but only when I'm confident it is properly tested.
Sorry to hammer you with change requests :P. I just thought that allowing recursion in migration directories would make a practical implementation of different migration environments easier. For example:
With this setup, you can see that as you create schema modifications in
schema
, they're automatically included in both of the environment folders,dev
andprod
, while these respective folders can add migrations of their own. However, this only works if thefind_migrations
command relaxes itsmax-depth
parameter.