mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Handle Jake's Suggestions
This commit is contained in:
+646
-652
File diff suppressed because it is too large
Load Diff
@@ -2,16 +2,14 @@
|
||||
|
||||
use Appwrite\Event\Event;
|
||||
use Appwrite\Messaging\Adapter\Realtime;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Appwrite\Permission;
|
||||
use Appwrite\Query;
|
||||
use Appwrite\Resque\Worker;
|
||||
use Appwrite\Role;
|
||||
use Appwrite\Utopia\Response\Model\Migration;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Transfer\Destination;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Transfer\Destinations\Appwrite as DestinationsAppwrite;
|
||||
use Utopia\Transfer\Resource;
|
||||
use Utopia\Transfer\Source;
|
||||
@@ -21,10 +19,10 @@ use Utopia\Transfer\Sources\NHost;
|
||||
use Utopia\Transfer\Sources\Supabase;
|
||||
use Utopia\Transfer\Transfer;
|
||||
|
||||
require_once __DIR__ . '/../init.php';
|
||||
require_once __DIR__.'/../init.php';
|
||||
|
||||
Console::title('Migrations V1 Worker');
|
||||
Console::success(APP_NAME . ' Migrations worker v1 has started');
|
||||
Console::success(APP_NAME.' Migrations worker v1 has started');
|
||||
|
||||
class MigrationsV1 extends Worker
|
||||
{
|
||||
@@ -37,7 +35,7 @@ class MigrationsV1 extends Worker
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return "migrations";
|
||||
return 'migrations';
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
@@ -56,11 +54,10 @@ class MigrationsV1 extends Worker
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle Event execution.
|
||||
*/
|
||||
if (!empty($events)) {
|
||||
if (! empty($events)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,6 +70,7 @@ class MigrationsV1 extends Worker
|
||||
* Process Source
|
||||
*
|
||||
* @return Source
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function processSource(string $source, array $credentials): Source
|
||||
@@ -88,7 +86,7 @@ class MigrationsV1 extends Worker
|
||||
$credentials['endpoint'],
|
||||
$credentials['apiKey'],
|
||||
$credentials['databaseHost'],
|
||||
"postgres",
|
||||
'postgres',
|
||||
$credentials['username'],
|
||||
$credentials['password'],
|
||||
$credentials['port'],
|
||||
@@ -264,6 +262,7 @@ class MigrationsV1 extends Worker
|
||||
|
||||
$migrationDocument->setAttribute('errors', $errorMessages);
|
||||
$this->updateMigrationDocument($migrationDocument, $projectDocument);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -278,6 +277,7 @@ class MigrationsV1 extends Worker
|
||||
$migrationDocument->setAttribute('status', 'failed');
|
||||
$migrationDocument->setAttribute('stage', 'finished');
|
||||
$migrationDocument->setAttribute('errors', [$th->getMessage()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ abstract class MigrationTest extends TestCase
|
||||
/**
|
||||
* Runs every document fix twice, to prevent corrupted data on multiple migrations.
|
||||
*
|
||||
* @param Document $document
|
||||
* @param Document $document
|
||||
*/
|
||||
protected function fixDocument(Document $document)
|
||||
{
|
||||
return $this->method->invokeArgs($this->migration, [
|
||||
$this->method->invokeArgs($this->migration, [$document])
|
||||
$this->method->invokeArgs($this->migration, [$document]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ abstract class MigrationTest extends TestCase
|
||||
*/
|
||||
public function testMigrationVersions(): void
|
||||
{
|
||||
require_once __DIR__ . '/../../../app/init.php';
|
||||
require_once __DIR__.'/../../../app/init.php';
|
||||
|
||||
foreach (Migration::$versions as $class) {
|
||||
$this->assertTrue(class_exists('Appwrite\\Migration\\Version\\' . $class));
|
||||
$this->assertTrue(class_exists('Appwrite\\Migration\\Version\\'.$class));
|
||||
}
|
||||
// Test if current version exists
|
||||
// Only test official releases - skip if latest is release candidate
|
||||
if (!(\str_contains(APP_VERSION_STABLE, 'RC'))) {
|
||||
if (! (\str_contains(APP_VERSION_STABLE, 'RC'))) {
|
||||
$this->assertArrayHasKey(APP_VERSION_STABLE, Migration::$versions);
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ abstract class MigrationTest extends TestCase
|
||||
'a' => true,
|
||||
'b' => 'abc',
|
||||
'c' => 123,
|
||||
'd' => ['a', 'b', 'c']
|
||||
]
|
||||
'd' => ['a', 'b', 'c'],
|
||||
],
|
||||
], [
|
||||
'bool' => true,
|
||||
'string' => 'abc',
|
||||
@@ -71,8 +71,8 @@ abstract class MigrationTest extends TestCase
|
||||
'a' => true,
|
||||
'b' => 'abc',
|
||||
'c' => 123,
|
||||
'd' => ['a', 'b', 'c']
|
||||
]
|
||||
'd' => ['a', 'b', 'c'],
|
||||
],
|
||||
]));
|
||||
$this->assertFalse(Migration::hasDifference([
|
||||
'bool' => true,
|
||||
@@ -83,15 +83,15 @@ abstract class MigrationTest extends TestCase
|
||||
'a' => true,
|
||||
'b' => 'abc',
|
||||
'c' => 123,
|
||||
'd' => ['a', 'b', 'c']
|
||||
]
|
||||
'd' => ['a', 'b', 'c'],
|
||||
],
|
||||
], [
|
||||
'string' => 'abc',
|
||||
'assoc' => [
|
||||
'a' => true,
|
||||
'b' => 'abc',
|
||||
'c' => 123,
|
||||
'd' => ['a', 'b', 'c']
|
||||
'd' => ['a', 'b', 'c'],
|
||||
],
|
||||
'int' => 123,
|
||||
'array' => ['a', 'b', 'c'],
|
||||
@@ -99,40 +99,40 @@ abstract class MigrationTest extends TestCase
|
||||
|
||||
]));
|
||||
$this->assertTrue(Migration::hasDifference([
|
||||
'a' => true
|
||||
'a' => true,
|
||||
], [
|
||||
'b' => true
|
||||
'b' => true,
|
||||
]));
|
||||
$this->assertTrue(Migration::hasDifference([
|
||||
'a' => 'true'
|
||||
'a' => 'true',
|
||||
], [
|
||||
'a' => true
|
||||
'a' => true,
|
||||
]));
|
||||
$this->assertTrue(Migration::hasDifference([
|
||||
'a' => true
|
||||
'a' => true,
|
||||
], [
|
||||
'a' => false
|
||||
'a' => false,
|
||||
]));
|
||||
$this->assertTrue(Migration::hasDifference([
|
||||
'nested' => [
|
||||
'a' => true
|
||||
]
|
||||
'a' => true,
|
||||
],
|
||||
], [
|
||||
'nested' => []
|
||||
'nested' => [],
|
||||
]));
|
||||
$this->assertTrue(Migration::hasDifference([
|
||||
'assoc' => [
|
||||
'bool' => true,
|
||||
'string' => 'abc',
|
||||
'int' => 123,
|
||||
'array' => ['a', 'b', 'c']
|
||||
]
|
||||
'array' => ['a', 'b', 'c'],
|
||||
],
|
||||
], [
|
||||
'nested' => [
|
||||
'a' => true,
|
||||
'int' => '123',
|
||||
'array' => ['a', 'b', 'c']
|
||||
]
|
||||
'array' => ['a', 'b', 'c'],
|
||||
],
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user