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

[BUG] Migration documentation leads to misfunctioning migrations #873

Open
thorin-schiffer opened this issue Feb 21, 2024 · 1 comment
Open
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@thorin-schiffer
Copy link

thorin-schiffer commented Feb 21, 2024

Describe the bug
Example for iterative migration will lead to migration being not applied to any document.

To Reproduce

class Tag(BaseModel):
    color: str
    name: str


class OldNote(Document):
    name: str
    tag: Tag

    class Settings:
        name = "notes"


class Note(Document):
    title: str
    tag: Tag

    class Settings:
        name = "notes"

makes an impression that if there is a model called Car, the name should be 'cars' (it is like this in Django for example). Instead, if no other name was specified, the actual collection for Car is 'Car', the same name as the model name. This leads to a situation, where migration creates a new collection named cars and so iterative migration iterates over a new empty collection, resulting in nothing happening. This is very confusing for new users, as they see no output and don't know if migration ran at all.

Besides, as it's probable that the user will rename the model to some versions of it, like NewCar and OldCar, it's beneficial to mention that the name argument is then crucial to point to the existing collection.

Expected behavior
I would prefer migrations not to create new collections implicitly at all. If that is not possible, update the documentation to remove ambiguity.

@roman-right roman-right added bug Something isn't working documentation Improvements or additions to documentation labels Feb 26, 2024
@roman-right
Copy link
Member

Hi! Thank you for the catch! It should be mentioned in the doc. I'll think about if the collection should be or should not be created at this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants