Skip to content

Add migrations for removing views and materialized views#106

Merged
mikicz merged 6 commits intomainfrom
feature/migrations
Jan 2, 2026
Merged

Add migrations for removing views and materialized views#106
mikicz merged 6 commits intomainfrom
feature/migrations

Conversation

@mikicz
Copy link
Collaborator

@mikicz mikicz commented Dec 23, 2025

This hooks into the migration system to register views into state, and then using that we can detect that a view was renamed / deleted / changed between types of view, so we can drop the mat views.

The register is only a state operation for now, handling view creation remains the same.

Fixes #34
Fixes #59 (not automatic but adds a nice solution)

@mikicz mikicz force-pushed the feature/migrations branch from e40b35b to a782ddd Compare January 2, 2026 10:50
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
django_pgviews
   checks.py13746%11, 13, 15–16, 18, 25, 41
django_pgviews/db/migrations
   operations.py801285%49, 54, 65–67, 87, 107–109, 113, 120, 133
django_pgviews/management/commands
   makemigrations.py440%1, 3, 6–7
TOTAL7565592% 

Tests Skipped Failures Errors Time
1376 0 💤 0 ❌ 0 🔥 46.150s ⏱️

@mikicz mikicz force-pushed the feature/migrations branch from a782ddd to a049030 Compare January 2, 2026 11:31
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this file

@mikicz mikicz force-pushed the feature/migrations branch from a049030 to bb18739 Compare January 2, 2026 11:34
@mikicz mikicz marked this pull request as ready for review January 2, 2026 11:35
@mikicz mikicz force-pushed the feature/migrations branch from bb18739 to bfe1328 Compare January 2, 2026 13:15
@mikicz mikicz requested a review from almeida-raphael January 2, 2026 14:29
@almeida-raphael
Copy link

There is a few things I would prefer to be type hinted that are not, other than that all good to go

@almeida-raphael
Copy link

Since it is minor you might chose to ignore, that is why I approved

@mikicz
Copy link
Collaborator Author

mikicz commented Jan 2, 2026

Since it is minor you might chose to ignore, that is why I approved

Pyrefly is not complaining 🤷

@mikicz mikicz changed the title Add "migrations" for views and materialized views Add migrations for removing views and materialized views Jan 2, 2026
@mikicz mikicz merged commit f84e034 into main Jan 2, 2026
28 checks passed
@mikicz mikicz deleted the feature/migrations branch January 2, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Drop views before migration Create a migration deleting the view/materialized view when a view is removed

2 participants