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

feat: migrations #4

Merged
merged 4 commits into from
Nov 14, 2022
Merged

feat: migrations #4

merged 4 commits into from
Nov 14, 2022

Conversation

roman-right
Copy link
Member

No description provided.

logger.info("Building migration list")
names = []
for modulepath in path.glob("*.py"):
names.append(modulepath.name)
Copy link

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.

Copy link
Member Author

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/
Copy link

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?

Copy link
Member Author

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_

@roman-right roman-right merged commit 6ba0d7d into main Nov 14, 2022
@roman-right
Copy link
Member Author

Hi @PetrF0X,
Please try 1.0.0. Things, discussed here, are there.

@PetrF0X
Copy link

PetrF0X commented Nov 15, 2022

Hi @roman-right,
I tried it and I loved it!
Thanks!

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

Successfully merging this pull request may close these issues.

2 participants