File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 11import pytest
22from django .core .management import call_command
3+ from django .db import connection
34
45from tests .asserts_utils import is_view_exists
56from tests .decorators import roll_back_schema
@@ -57,6 +58,12 @@ def test_materialized_db_view_based_on_raw_sql_with_indexes(
5758 SimpleMaterializedViewWithIndex .objects .get ().current_date_time
5859 )
5960 assert current_date_time_from_view_call_1 != current_date_time_from_view_call_3
61+ # Create a unique index required for concurrent refresh
62+ with connection .cursor () as cursor :
63+ cursor .execute (
64+ f"CREATE UNIQUE INDEX IF NOT EXISTS unique_idx_current_date_time "
65+ f"ON { SimpleMaterializedViewWithIndex ._meta .db_table } (current_date_time)"
66+ )
6067 # regular refresh concurrently
6168 SimpleMaterializedViewWithIndex .refresh (concurrently = True )
6269 current_date_time_from_view_call_4 = (
You can’t perform that action at this time.
0 commit comments