Failed to create indexes for collection 'user_details': Unknown attribute: firstName
- 0
- Self Hosted
- Databases
Hi everyone, i am using a python script in order to seed my database and so far i am able to do so but it fails on the index creation. I am running appwrite version 1.5.4 self hosted. However when it tries to create the indexes it fails with the following message :Failed to create indexes for collection 'user_details': Unknown attribute: firstName
. Here is the code i use to create the indexes i even check that the attributes i require for the index exists # Create collection indexes for user_details
try:
user_details_collection = databases.get_collection(
database_id=database_id, collection_id=collection_ids["user_details"]
)
user_details_attributes = [
attr["key"] for attr in user_details_collection["attributes"]
]
if (
"firstName" in user_details_attributes
and "lastName" in user_details_attributes
and not user_details_collection["indexes"]
):
databases.create_index(
database_id=database_id,
collection_id=collection_id,
key="nameIndex",
type=IndexType.UNIQUE,
attributes=["firstName", "lastName"],
)
databases.create_index(
database_id=database_id,
collection_id=collection_id,
key="dobIndex",
type=IndexType.KEY,
attributes=["dateOfBirth"],
)
else:
print(
f"Cannot create indexes for collection '{collection}': Required attributes do not exist."
)
except Exception as e:
print(f"Failed to create indexes for collection 'user_details': {str(e)}")
What do i do wrong ?
Recommended threads
- Seed db
hello there... is this correct way to seed appwrite
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...