1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13:00
This commit is contained in:
fogelito 2023-03-13 11:34:41 +02:00
parent b6c279b576
commit 5fc3f5bc3a
2 changed files with 21 additions and 3 deletions

View file

@ -123,7 +123,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att
'format' => $format,
'formatOptions' => $formatOptions,
'filters' => $filters,
'options' => $options, // Do we want all of the options?
'options' => $options, // Do we want all options?
]);
$dbForProject->checkAttribute($collection, $attribute);

View file

@ -4,6 +4,7 @@ use Appwrite\Event\Event;
use Appwrite\Messaging\Adapter\Realtime;
use Appwrite\Resque\Worker;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
require_once __DIR__ . '/../init.php';
@ -73,7 +74,7 @@ class DatabaseV1 extends Worker
'collectionId' => $collection->getId(),
'attributeId' => $attribute->getId()
]);
/**
/**x
* Fetch attribute from the database, since with Resque float values are loosing informations.
*/
$attribute = $dbForProject->getDocument('attributes', $attribute->getId());
@ -89,12 +90,29 @@ class DatabaseV1 extends Worker
$format = $attribute->getAttribute('format', '');
$formatOptions = $attribute->getAttribute('formatOptions', []);
$filters = $attribute->getAttribute('filters', []);
$options = $attribute->getAttribute('options', []);
$project = $dbForConsole->getDocument('projects', $projectId);
try {
if (!$dbForProject->createAttribute('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $key, $type, $size, $required, $default, $signed, $array, $format, $formatOptions, $filters)) {
if ($type === Database::VAR_RELATIONSHIP) {
if (
!$dbForProject->createRelationship(
collection: 'make',
relatedCollection: 'model',
type: $options['type'],
twoWay: $options['twoWay'],
id: $options['id'],
twoWayKey: $options['twoWayKey'],
onUpdate: $options['onUpdate'],
onDelete: $options['onDelete'],
)
) {
throw new Exception('Failed to create Attribute');
}
} elseif (!$dbForProject->createAttribute('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $key, $type, $size, $required, $default, $signed, $array, $format, $formatOptions, $filters)) {
throw new Exception('Failed to create Attribute');
}
$dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'available'));
} catch (\Throwable $th) {
Console::error($th->getMessage());