Materilized view Index management and replace view migrations#1
Draft
Materilized view Index management and replace view migrations#1
Conversation
Collaborator
tonisvain
commented
Nov 28, 2025
- Adds CREATE OR REPLACE VIEW support for regular views with auto-detection (PostgreSQL/MySQL) to enable atomic updates.
- Implements automatic index management for materialized views, detecting and migrating all index types alongside view definitions. Both features include user override capabilities.
Add comprehensive tests for materialized view index detection
- Add helper functions to tests/asserts_utils.py for index verification
- get_index_names(): Get all index names for a table
- index_exists(): Check if specific index exists
- get_index_definition(): Get full index definition from database
- Add MaterializedViewWithMultipleIndexesTemplate test model
- Supports testing multiple index types and configurations
- Create tests/test_materialized_view_indexes.py with 8 test cases:
- Test basic index detection with get_migration_indexes()
- Test index recreation when view definition changes
- Test multiple indexes with different properties (unique, partial, multi-column)
- Test forward and backward migration with indexes
- Test views without indexes don't generate index operations
- Test index definition formatting (USING btree)
- Test no duplicate operations on subsequent makeviewmigrations
- Enable previously skipped test for materialized views with indexes
- Remove @pytest.mark.skip from test_materialized_db_view_based_on_raw_sql_with_indexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.