Skip to content
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

Custom migration directory #68

Open
ilyakaznacheev opened this issue Apr 27, 2019 · 4 comments
Open

Custom migration directory #68

ilyakaznacheev opened this issue Apr 27, 2019 · 4 comments

Comments

@ilyakaznacheev
Copy link
Contributor

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.

@vmihailenco
Copy link
Member

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.

@ilyakaznacheev
Copy link
Contributor Author

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.

@Ragnar-BY
Copy link

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?

@ohmpatel1997
Copy link

ohmpatel1997 commented Nov 15, 2021

DiscoverSQLMigrations does not discover the .go files. Is there any way to discover the go file as well.

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

No branches or pull requests

4 participants