dwyl / learn-phoenix

:fire: Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. :rocket:
650 stars 45 forks source link

Add info on using a .gitkeep to push migrations directory #108

Open ZooeyMiller opened 7 years ago

ZooeyMiller commented 7 years ago

As noted by @katbow in https://github.com/dwyl/library/pull/4#pullrequestreview-69195376 it's really useful to use a .gitkeep so that git tracks your empty migrations directory (when you've just created a phoenix project and haven't made any migrations yet). It also means that your travis build will still pass. Without a migrations directory the build will fail.

We should add this info to the readme!

SimonLab commented 7 years ago

I'm not a big fan of .gitkeep files. It's true they resolve the problem with the empty migration folder but for me it feels a bit weird to create a specific file just to please git. I prefer create an empty migration file at the start and then update this file when a migration is needed. Also as soon as a migration is created often the .gitkeep file is forgotten and left in the folder.

katbow commented 7 years ago

Fair enough point that it can be forgotten about. But I think the same is possible with an empty migration file i.e. I would likely go through my usual flow of generating a migration the next time I need one and forget about the one that's already there. That also ensures the migration name matches up with what it's doing. Whereas, if I make an empty one to start with a random name, I end up also needing to change that or the file name may not be reflective of the content.

It's a bit of preference, but really the overall point is to somehow ensure you have this directory so that Travis can still pass, and other people cloning the repo will have that available in the correct place.

ZooeyMiller commented 7 years ago

If it's controversial I'm unsure of what to add in a PR. Perhaps we could offer both as options but just clarify there needs to be some kind of file there for travis to pass and people pulling the repo?

nelsonic commented 7 years ago

.gitkeep files are not part of the Git spec; they are a "work-around" ... https://git.wiki.kernel.org/index.php?search=gitkeep image more detail in: https://stackoverflow.com/a/7229996/1148249

The preference in the Phoenix community appears to be for an Empty migration file that gets deleted once the project has a "real" migration.