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

Testing: compatibility with -no-migrations mode #24

Open
benjaminrigaud opened this issue Apr 12, 2023 · 5 comments
Open

Testing: compatibility with -no-migrations mode #24

benjaminrigaud opened this issue Apr 12, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@benjaminrigaud
Copy link

benjaminrigaud commented Apr 12, 2023

When running pytest --no-migrations, Models are synced to their corresponding tables as-is: no migrations are executed.

django-db-views doesn't support this mode: the views are not created and the tests fail.

As a workaround, I have implemented a fixture to be able to apply any migration on the fly.

A proper implementation in django-db-views could be to uncouple the SQL creating the views from the migration framework: it would permit the creation of a few helper to execute this SQL outside of the migrations (django-pgtrigger does something like that).

What are your thoughts?

References:

@BezBartek
Copy link
Owner

@benjaminrigaud
Thank you for your thoughts
I will try to get deeper into it through the weekend

@BezBartek BezBartek added the enhancement New feature or request label Apr 14, 2023
@benjaminrigaud
Copy link
Author

Hi,

If I implement a fix, would you have time to review it? 🙇

Ben

@BezBartek
Copy link
Owner

Hello @benjaminrigaud
Please do so, thank you!
Apologize that I didn't find time to write it
I will review your code and merge

@lajus
Copy link

lajus commented Aug 29, 2024

Hello,

I have run into the same issue while experimenting with django-db-views on my project.

@benjaminrigaud you said

As a workaround, I have implemented a fixture to be able to apply any migration on the fly.

would it be possible for you to share the code of your fixture ?

Thanks,
Jonathan

@benjaminrigaud
Copy link
Author

would it be possible for you to share the code of your fixture ?

Sorry @lajus, I can't share that code from a private Repo.

Some details:

  • It uses __import__ to import the migration module
  • Then instantiates the Migration class from this module
  • Then it calls migration.apply(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants