Skip to content

Materilized view Index management and replace view migrations#1

Draft
tonisvain wants to merge 14 commits intomasterfrom
feature/view-improvements
Draft

Materilized view Index management and replace view migrations#1
tonisvain wants to merge 14 commits intomasterfrom
feature/view-improvements

Conversation

@tonisvain
Copy link
Copy Markdown
Collaborator

  • 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
@lnagel lnagel marked this pull request as draft December 3, 2025 14:46
@lnagel lnagel self-requested a review December 3, 2025 14:46
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.

1 participant