#17: Fail fast when migrations dir cannot be resolved #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr; Mitigates the issue: #17
Details:
When application is running by IDE generated quick run play button:
It automatically sets working directory to
beebot/initiator
sub-directory of the repository, because such entry point is located in that directory. At the same time, whenyoyo
reads migrations:it does use relative to the working directory path, however, even if such path does not exist, the library silently returns empty MigrationList:
which leads to missing schema and fails later in the code path that accesses the entity.
This approach fails fast preventing application from running on the unexpected working directory.
Alternative approach would be to resolve migrations directory relative to
database_models.py
:With this approach the part responsible for migrations will successfully locate migrations in regardless of working directory:
At the same time, the code becomes coupled to the
database_models.py
andmigrations
locations and also does not fix possibility for other places in code to rely on the repository layout.Best practice in general would be to locate migrations within source code module, so it can be referenced from the source code root as python modules do right now.
Please let me know if this simple fail fast solution enough or you prefer anything else.