-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
git does not commit "versions" by default, so we should possibly ensure some file is present there #1320
Comments
I wouldnt want to do that. the the issue here is git's behavior of not including empty folders. The only real way to work around this is to have a file present in ./versions; right now this can be achieved using I would propose some other kind of file in the templates like a README.rst with a single line. @CaselIT thoughts? |
not sure, I can't think of a reason why someone would be surprised by it. |
yah i googled a bit, is .gitkeep a convention of some kind ? seems to be used a lot, though then you see things like https://adamj.eu/tech/2023/09/18/git-dont-create-gitkeep/ . .gitkeep is only a convention, not recognized by git itself. should we use the .,gitignore convention approach instead? I have seen that mentioned a few places. |
First: I don't particularly have a horse in the race myself other than uncovering the issue somewhat by mistake. To me it makes the most sense to have an empty __init__.py in the versions folder because alembic itself has no real responsibility to make sure git behaves (imho) so there's no real need for .gitignore or .gitkeep, just for alembic to accurately and cleanly tell the user what the problem is. The idea of autoinstantiation was more about user experience, but it seems like "ERROR: versions directory does not exist" or something similar would be more than enough. Anyway, thanks for jumping on this so quickly. |
IIRC the |
I don't think it applies in this case, since we aren't trying to ignore everything inside version. I think |
Describe the bug
Creating a revision fails if the
versions
directory is missingExpected behavior
versions directory is created, then revision is created or a clean error message explaining the problem
To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.
Error
Versions.
Additional context
This is a corner case. I initialized alembic and due to the timing, committed after the initialization but before creating the first migration. The versions directory was empty and was not preserved. I moved to a different device and ran a pull, then tried to create the initial revision. That failed.
As you may note from the above, I am using pdm and initially thought there was a pathing issue. That is not the case - I activated the virtualenv and was able to reproduce.
Obviously this is a bit of a silly issue, as it's unlikely many people are going to initialize alembic and then not create an initial revision, but it could happen to someone else. I suspect that autoinstantiating the versions directory if not present is probably the easiest behavior to include, but if that can't happen for some reason (lacking create permissions/device full/other things) catching the issue and then producing a clear error message seems like the right thing.
Have a nice day!
The text was updated successfully, but these errors were encountered: