Back

Uncaught Appwrite\AppwriteException: Attribute not available: name

  • 0
  • Self Hosted
  • Databases
cydrickn
11 Jun, 2024, 02:14

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.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more