-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: migrations #4
Conversation
bunnet/migrations/runner.py
Outdated
logger.info("Building migration list") | ||
names = [] | ||
for modulepath in path.glob("*.py"): | ||
names.append(modulepath.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @roman-right, could __init__.py
be excluded here?
The problem we're facing is that only the initial scripts are run (and any later added migration files are ignored in further runs).
This is because the first migration creates following records in migrations_log
(_id
and ts
omitted):
name: 20221103203943_migration_test.py, is_current: false
name: 20221103204129_migration_test_2.py, is_current: false
name: __init__.py, is_current: true
and newly added migration files (which names start with a timestamp) never appear after __init__.py
when sorted alphabetically.
We wish to have __init__.py
in the package along with the migration files in order to be able to import the migration files in unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @PetrF0X ,
Good point! I'll exclude init file there. Thank you.
To create a new migration, run: | ||
|
||
```shell | ||
bunnet new-migration -n migration_name -p relative/path/to/migrations/directory/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @roman-right,
I couldn't find the code that handles this command so I'll stick my comment here - we've noticed that the generated file name makes it hard for the migration file to be imported in a unit test (the filename starts with a number).
Would you consider a different naming convention for the migration files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. Yes, you are right. I think, I'll add a prefix like migration_
Hi @PetrF0X, |
Hi @roman-right, |
No description provided.