updated project and migraiton worker

This commit is contained in:
ArnabChatterjee20k
2026-02-09 17:43:42 +05:30
parent 3b2eb02f8a
commit 8e140bae6c
4 changed files with 115 additions and 137 deletions
-2
View File
@@ -14,8 +14,6 @@ use Appwrite\SDK\Deprecated;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Template\Template;
use Appwrite\Utopia\Database\Validator\ProjectId;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use PHPMailer\PHPMailer\PHPMailer;
use Utopia\Config\Config;
Generated
+24 -45
View File
@@ -3367,49 +3367,28 @@
"utopia-php/database": "5.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
"phpstan/phpstan": "1.9.x-dev",
"phpunit/phpunit": "^9.3",
"vimeo/psalm": "4.0.1"
"laravel/pint": "1.*",
"phpbench/phpbench": "1.*",
"phpstan/phpstan": "1.*",
"phpunit/phpunit": "9.*"
},
"type": "library",
"autoload": {
"psr-4": {
"Utopia\\Agents\\": "src/Agents"
"Utopia\\Abuse\\": "src/Abuse"
}
},
"autoload-dev": {
"psr-4": {
"Utopia\\Tests\\Agents\\": "tests/Agents"
}
},
"scripts": {
"check": [
"./vendor/bin/phpstan analyse --level max src tests"
],
"lint": [
"./vendor/bin/pint --test"
],
"format": [
"./vendor/bin/pint"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Utopia PHP",
"email": "team@appwrite.io"
}
],
"description": "A simple PHP AI agents library",
"description": "A simple abuse library to manage application usage limits",
"keywords": [
"agents",
"ai",
"automation",
"machine-learning",
"php"
"Abuse",
"framework",
"php",
"upf",
"utopia"
],
"support": {
"issues": "https://github.com/utopia-php/abuse/issues",
@@ -4073,16 +4052,16 @@
},
{
"name": "utopia-php/domains",
"version": "1.0.0",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/domains.git",
"reference": "ecac82392e83d4a8ede76c3c94258d868d82f709"
"reference": "20b6a6868234d766fef35a47814dccc66906c2af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/domains/zipball/ecac82392e83d4a8ede76c3c94258d868d82f709",
"reference": "ecac82392e83d4a8ede76c3c94258d868d82f709",
"url": "https://api.github.com/repos/utopia-php/domains/zipball/20b6a6868234d766fef35a47814dccc66906c2af",
"reference": "20b6a6868234d766fef35a47814dccc66906c2af",
"shasum": ""
},
"require": {
@@ -4129,9 +4108,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/domains/issues",
"source": "https://github.com/utopia-php/domains/tree/1.0.0"
"source": "https://github.com/utopia-php/domains/tree/1.0.1"
},
"time": "2026-01-30T06:15:50+00:00"
"time": "2026-02-06T12:45:12+00:00"
},
{
"name": "utopia-php/dsn",
@@ -5558,16 +5537,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "1.8.25",
"version": "1.8.26",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "5c75fda3410fe97387ef8e1920b583ef48849d7d"
"reference": "ce65854069a1af8ef0757650da5848168cca5f02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5c75fda3410fe97387ef8e1920b583ef48849d7d",
"reference": "5c75fda3410fe97387ef8e1920b583ef48849d7d",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ce65854069a1af8ef0757650da5848168cca5f02",
"reference": "ce65854069a1af8ef0757650da5848168cca5f02",
"shasum": ""
},
"require": {
@@ -5603,9 +5582,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/1.8.25"
"source": "https://github.com/appwrite/sdk-generator/tree/1.8.26"
},
"time": "2026-02-05T09:40:07+00:00"
"time": "2026-02-08T07:41:27+00:00"
},
{
"name": "doctrine/annotations",
@@ -93,103 +93,104 @@ class Create extends Action
}
// for returning dsn of multitype dbs with type optionally based on input dsn
protected function getDatabaseDSN(string $databasetype, $region, ?string $dsn = null): string {
$isSharedTablesV1 = false;
$isSharedTablesV2 = false;
if (!empty($dsn)) {
try {
$parsedDsn = new DSN($dsn);
$dsnHost = $parsedDsn->getHost();
} catch (\InvalidArgumentException) {
$dsnHost = $dsn;
}
protected function getDatabaseDSN(string $databasetype, $region, ?string $dsn = null): string
{
$isSharedTablesV1 = false;
$isSharedTablesV2 = false;
if (!empty($dsn)) {
try {
$parsedDsn = new DSN($dsn);
$dsnHost = $parsedDsn->getHost();
} catch (\InvalidArgumentException) {
$dsnHost = $dsn;
}
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', ''));
$sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1);
$isSharedTablesV1 = \in_array($dsnHost, $sharedTablesV1);
$isSharedTablesV2 = \in_array($dsnHost, $sharedTablesV2);
}
$databases = [];
$databaseKeys = [];
/**
* @var string|null $databaseOverride
*/
$databaseOverride = '';
$dbScheme = '';
$sharedTables = [];
$sharedTablesV1 = [];
$sharedTablesV2 = [];
switch ($databasetype) {
case 'documentsDatabase':
$databases = Config::getParam('pools-documentsdb', []);
$databaseKeys = System::getEnv('_APP_DATABASE_DOCUMENTSDB_KEYS', '');
$databaseOverride = System::getEnv('_APP_DATABASE_DOCUMENTSDB_OVERRIDE');
$dbScheme = System::getEnv('_APP_DB_HOST_DOCUMENTSDB', 'mongodb');
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES_V1', ''));
break;
case 'vectorDatabase':
$databases = Config::getParam('pools-vectordb', []);
$databaseKeys = System::getEnv('_APP_DATABASE_VECTORDB_KEYS', '');
$databaseOverride = System::getEnv('_APP_DATABASE_VECTORDB_OVERRIDE');
$dbScheme = System::getEnv('_APP_DB_HOST_VECTORDB', 'postgresql');
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES_V1', ''));
break;
default:
// legacy/tablesdb
$databases = Config::getParam('pools-database', []);
$databaseKeys = System::getEnv('_APP_DATABASE_KEYS', '');
$databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE');
$dbScheme = System::getEnv('_APP_DB_HOST', 'mysql');
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', ''));
$sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1);
$isSharedTablesV1 = \in_array($dsnHost, $sharedTablesV1);
$isSharedTablesV2 = \in_array($dsnHost, $sharedTablesV2);
}
break;
}
$databases = [];
$databaseKeys = [];
/**
* @var string|null $databaseOverride
*/
$databaseOverride = '';
$dbScheme = '';
$sharedTables = [];
$sharedTablesV1 = [];
$sharedTablesV2 = [];
if ($region !== 'default') {
$keys = explode(',', $databaseKeys);
$databases = array_filter($keys, function ($value) use ($region) {
return str_contains($value, $region);
});
}
$sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1);
switch ($databasetype) {
case 'documentsDatabase':
$databases = Config::getParam('pools-documentsdb', []);
$databaseKeys = System::getEnv('_APP_DATABASE_DOCUMENTSDB_KEYS', '');
$databaseOverride = System::getEnv('_APP_DATABASE_DOCUMENTSDB_OVERRIDE');
$dbScheme = System::getEnv('_APP_DB_HOST_DOCUMENTSDB', 'mongodb');
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES_V1', ''));
break;
case 'vectorDatabase':
$databases = Config::getParam('pools-vectordb', []);
$databaseKeys = System::getEnv('_APP_DATABASE_VECTORDB_KEYS', '');
$databaseOverride = System::getEnv('_APP_DATABASE_VECTORDB_OVERRIDE');
$dbScheme = System::getEnv('_APP_DB_HOST_VECTORDB', 'postgresql');
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES_V1', ''));
break;
default:
// legacy/tablesdb
$databases = Config::getParam('pools-database', []);
$databaseKeys = System::getEnv('_APP_DATABASE_KEYS', '');
$databaseOverride = System::getEnv('_APP_DATABASE_OVERRIDE');
$dbScheme = System::getEnv('_APP_DB_HOST', 'mysql');
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', ''));
break;
}
if ($region !== 'default') {
$keys = explode(',', $databaseKeys);
$databases = array_filter($keys, function ($value) use ($region) {
return str_contains($value, $region);
});
}
$sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1);
$index = \array_search($databaseOverride, $databases);
if ($index !== false) {
$selectedDsn = $databases[$index];
} else {
if (!empty($dsn)) {
if ($isSharedTablesV1) {
$databases = array_filter($databases, fn ($value) => \in_array($value, $sharedTablesV1));
} elseif ($isSharedTablesV2) {
$databases = array_filter($databases, fn ($value) => \in_array($value, $sharedTablesV2));
} else {
$databases = array_filter($databases, fn ($value) => !\in_array($value, $sharedTables));
}
}
$selectedDsn = !empty($databases) ? $databases[array_rand($databases)] : '';
}
if (\in_array($selectedDsn, $sharedTables)) {
$schema = 'appwrite';
$database = 'appwrite';
$namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', '');
$selectedDsn = $schema . '://' . $selectedDsn . '?database=' . $database;
if (!empty($namespace)) {
$selectedDsn .= '&namespace=' . $namespace;
$index = \array_search($databaseOverride, $databases);
if ($index !== false) {
$selectedDsn = $databases[$index];
} else {
if (!empty($dsn)) {
if ($isSharedTablesV1) {
$databases = array_filter($databases, fn ($value) => \in_array($value, $sharedTablesV1));
} elseif ($isSharedTablesV2) {
$databases = array_filter($databases, fn ($value) => \in_array($value, $sharedTablesV2));
} else {
$databases = array_filter($databases, fn ($value) => !\in_array($value, $sharedTables));
}
}
try {
new DSN($selectedDsn);
} catch (\InvalidArgumentException) {
$selectedDsn = $dbScheme.'://' . $selectedDsn;
$selectedDsn = !empty($databases) ? $databases[array_rand($databases)] : '';
}
if (\in_array($selectedDsn, $sharedTables)) {
$schema = 'appwrite';
$database = 'appwrite';
$namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', '');
$selectedDsn = $schema . '://' . $selectedDsn . '?database=' . $database;
if (!empty($namespace)) {
$selectedDsn .= '&namespace=' . $namespace;
}
return $selectedDsn;
}
try {
new DSN($selectedDsn);
} catch (\InvalidArgumentException) {
$selectedDsn = $dbScheme.'://' . $selectedDsn;
}
return $selectedDsn;
}
public function action(string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForPlatform, Cache $cache, Group $pools, Hooks $hooks)
+1 -1
View File
@@ -192,7 +192,7 @@ class Migrations extends Action
$getDatabasesDB = fn (Document $database): Database =>
$this->getDatabasesDBForProject($database);
$queries = [];
if ($source === Appwrite::getName() && $destination === DestinationCSV::getName()) {
if ($source === SourceAppwrite::getName() && $destination === DestinationCSV::getName()) {
$queries = Query::parseQueries($migrationOptions['queries']);
}