
An error occured "Uncaught Appwrite\AppwriteException: Attribute not available: name" when creating index after creating attribute in just one script.
But if you run the create index using another script it will work.
SDK use: PHP
code example that causes the issue
TypeScript
<?php
require_once __DIR__ . '/vendor/autoload.php';
$client = new \Appwrite\Client();
$client->setEndpoint($_ENV['APPWRITE_ENDPOINT'])
->setProject($_ENV['APPWRITE_FUNCTION_PROJECT_ID'])
->setKey($_ENV['APPWRITE_API_KEY']);
$databaseId = $_ENV['APPWRITE_DATABASE_ID'];
$databases = new \Appwrite\Services\Databases($client);
$databases->createCollection($databaseId, 'regions', 'regions');
$databases->createStringAttribute($databaseId, 'regions', 'name', 64, true);
$databases->createStringAttribute($databaseId, 'regions', 'designation', 64, true);
$databases->createIndex($databaseId, 'regions', 'index_name', \Appwrite\Enums\IndexType::UNIQUE(), ['name']);
$databases->createIndex($databaseId, 'regions', 'index_design', \Appwrite\Enums\IndexType::UNIQUE(), ['designation']);
TL;DR
An error occurs when creating an index after creating an attribute in one script in Appwrite PHP SDK. The error message reads: "Uncaught Appwrite\AppwriteException: Attribute not available: name." However, running the create index using another script works.
The provided code example shows the process where the error occurs.Recommended threads
- My collection is not updating after csv ...
- Properly contained appwrite main app can...
Hello! We tried to reinstall our main self-hosted appwrite with a new method but the main app 2 mins after launch throw this error: ```2025/06/22 16:16:14 s...
- How do I format an array in a CSV file t...
I want to import a CSV file to create a document on it on the AppWrite website. I have an attribute "name" of type String and "ingredients" which is of type St...
