Skip to content

Commit bd24050

Browse files
author
Andrew Brookins
committed
Avoid creating the index if it already exists
1 parent ab85e46 commit bd24050

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

redis_developer/model/migrations/migrator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ def schema_hash_key(index_name):
4444

4545

4646
def create_index(index_name, schema, current_hash):
47+
try:
48+
redis.execute_command(f"ft.info {index_name}")
49+
except ResponseError:
50+
log.info("Index already exists, skipping. Index hash: %s", index_name)
51+
return
4752
redis.execute_command(f"ft.create {index_name} {schema}")
4853
redis.set(schema_hash_key(index_name), current_hash)
4954

0 commit comments

Comments
 (0)