Skip to content

Commit f5b5073

Browse files
author
Simon Prickett
committed
Adds error if user attempts to create an index in DB > 0.
1 parent c4e96b1 commit f5b5073

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

aredis_om/model/migrations/migrator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def schema_hash_key(index_name):
4040

4141

4242
async def create_index(redis: Redis, index_name, schema, current_hash):
43+
db_number = redis.connection_pool.connection_kwargs.get("db")
44+
if db_number and db_number > 0:
45+
raise MigrationError(
46+
"Creating search indexes is only supported in database 0. "
47+
f"You attempted to create an index in database {db_number}"
48+
)
4349
try:
4450
await redis.execute_command(f"ft.info {index_name}")
4551
except ResponseError:

0 commit comments

Comments
 (0)