Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Migration/Destinations/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ protected function createColumn(Column $resource): bool
Column::TYPE_EMAIL,
Column::TYPE_URL,
Column::TYPE_ENUM => UtopiaDatabase::VAR_STRING,
Column::TYPE_POINT => UtopiaDatabase::VAR_POINT,
Column::TYPE_LINE => UtopiaDatabase::VAR_LINESTRING,
Column::TYPE_POLYGON => UtopiaDatabase::VAR_POLYGON,
default => throw new \Exception('Invalid resource type '.$resource->getType()),
};

Expand Down
4 changes: 4 additions & 0 deletions src/Migration/Resources/Database/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ abstract class Column extends Resource
public const TYPE_URL = 'url';
public const TYPE_RELATIONSHIP = 'relationship';

public const TYPE_POINT = 'point';
public const TYPE_LINE = 'linestring';
public const TYPE_POLYGON = 'polygon';

/**
* @param string $key
* @param Table $table
Expand Down
74 changes: 74 additions & 0 deletions src/Migration/Resources/Database/Columns/Line.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Utopia\Migration\Resources\Database\Columns;

use Utopia\Migration\Resources\Database\Column;
use Utopia\Migration\Resources\Database\Table;

class Line extends Column
{
public function __construct(
string $key,
Table $table,
bool $required = false,
?array $default = null,
string $createdAt = '',
string $updatedAt = ''
) {
parent::__construct(
$key,
$table,
required: $required,
default: $default,
createdAt: $createdAt,
updatedAt: $updatedAt
);
}

/**
* @param array{
* key: string,
* collection?: array{
* database: array{
* id: string,
* name: string,
* },
* name: string,
* id: string,
* documentSecurity: bool,
* permissions: ?array<string>
* },
* table?: array{
* database: array{
* id: string,
* name: string,
* },
* name: string,
* id: string,
* rowSecurity: bool,
* permissions: ?array<string>
* },
* required: bool,
* default: ?array<mixed>,
* createdAt: string,
* updatedAt: string,
* } $array
* @return self
*/
public static function fromArray(array $array): self
{
return new self(
$array['key'],
Table::fromArray($array['table'] ?? $array['collection']),
required: $array['required'],
default: $array['default'],
createdAt: $array['createdAt'] ?? '',
updatedAt: $array['updatedAt'] ?? '',
);
}

public function getType(): string
{
return Column::TYPE_LINE;
}
}
74 changes: 74 additions & 0 deletions src/Migration/Resources/Database/Columns/Point.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Utopia\Migration\Resources\Database\Columns;

use Utopia\Migration\Resources\Database\Column;
use Utopia\Migration\Resources\Database\Table;

class Point extends Column
{
public function __construct(
string $key,
Table $table,
bool $required = false,
?array $default = null,
string $createdAt = '',
string $updatedAt = ''
) {
parent::__construct(
$key,
$table,
required: $required,
default: $default,
createdAt: $createdAt,
updatedAt: $updatedAt
);
}

/**
* @param array{
* key: string,
* collection?: array{
* database: array{
* id: string,
* name: string,
* },
* name: string,
* id: string,
* documentSecurity: bool,
* permissions: ?array<string>
* },
* table?: array{
* database: array{
* id: string,
* name: string,
* },
* name: string,
* id: string,
* rowSecurity: bool,
* permissions: ?array<string>
* },
* required: bool,
* default: ?array<mixed>,
* createdAt: string,
* updatedAt: string,
* } $array
* @return self
*/
public static function fromArray(array $array): self
{
return new self(
$array['key'],
Table::fromArray($array['table'] ?? $array['collection']),
required: $array['required'],
default: $array['default'],
createdAt: $array['createdAt'] ?? '',
updatedAt: $array['updatedAt'] ?? '',
);
}

public function getType(): string
{
return Column::TYPE_POINT;
}
}
Loading