Open ilyakaznacheev opened 5 years ago
We have https://godoc.org/github.com/go-pg/migrations#Collection.DiscoverSQLMigrations that allows to scan any directory for SQL migrations with few lines of code. I would not add those lines to the lib because it adds a dependency on the flags package and different people have different requirements.
So unless I miss something and it is more complicated - thanks, but no.
The point about a flag
lib sounds reasonable.
Then I would like to add an example of a custom directory discovery to example.
It's a really nice feature but not so well documented, so it took me to read all the sources to understand how I can use this feature without any breakage.
It also gives me the idea that the library needs a list of features like pg has.
I have similar question. How can I use custom migration directory, where not only sql, but go files are placed? For example, I want that command "go run *.go create add email to users" creates migration file in special folder "./migrations" not in root folder. Can use provide such option, please?
DiscoverSQLMigrations
does not discover the .go files. Is there any way to discover the go file as well.
It's very rare in big projects, that migration files are located in the same directory as an executable file or in the root directory. If the project implements the standard layout or is just big enough to have many parts and sub packages, migration files are normally stored in some place, far away from root or cmd directory.
I've implemented custom folder support on my project, that discovers migration files by the path, provided with the CLI parameter. But I would like to see and find it very useful to have such option out-of-the-box.
If it doesn't contradict the main idea of the library, I would like to implement it as an optional CLI argument, that defines a custom path to the migration directory.