replace old collections file
This commit is contained in:
parent
45fde3b2b9
commit
ac796048d8
1628
app/config/collections.old.php
Normal file
1628
app/config/collections.old.php
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -59,13 +59,11 @@ App::post('/v1/projects')
|
|||
->inject('dbForConsole')
|
||||
->inject('dbForInternal')
|
||||
->inject('dbForExternal')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $dbForConsole, $dbForInternal, $dbForExternal, $consoleDB) {
|
||||
->action(function ($projectId, $name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $dbForConsole, $dbForInternal, $dbForExternal) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Database\Database $dbForConsole */
|
||||
/** @var Utopia\Database\Database $dbForInternal */
|
||||
/** @var Utopia\Database\Database $dbForExternal */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
|
||||
$team = $dbForConsole->getDocument('teams', $teamId);
|
||||
|
||||
|
@ -106,7 +104,7 @@ App::post('/v1/projects')
|
|||
'search' => implode(' ', [$projectId, $name]),
|
||||
]));
|
||||
|
||||
$collections = Config::getParam('collections2', []); /** @var array $collections */
|
||||
$collections = Config::getParam('collections', []); /** @var array $collections */
|
||||
|
||||
$dbForInternal->setNamespace('project_' . $project->getId() . '_internal');
|
||||
$dbForInternal->create();
|
||||
|
@ -148,8 +146,6 @@ App::post('/v1/projects')
|
|||
$dbForInternal->createCollection($key, $attributes, $indexes);
|
||||
}
|
||||
|
||||
$consoleDB->createNamespace($project->getId());
|
||||
|
||||
$response->setStatusCode(Response::STATUS_CODE_CREATED);
|
||||
$response->dynamic($project, Response::MODEL_PROJECT);
|
||||
});
|
||||
|
|
|
@ -90,7 +90,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
if(!$dbForConsole->exists()) {
|
||||
Console::success('[Setup] - Server database init started...');
|
||||
|
||||
$collections = Config::getParam('collections2', []); /** @var array $collections */
|
||||
$collections = Config::getParam('collections', []); /** @var array $collections */
|
||||
|
||||
$redis->flushAll();
|
||||
|
||||
|
|
19
app/init.php
19
app/init.php
|
@ -128,7 +128,6 @@ Config::load('auth', __DIR__.'/config/auth.php');
|
|||
Config::load('providers', __DIR__.'/config/providers.php');
|
||||
Config::load('platforms', __DIR__.'/config/platforms.php');
|
||||
Config::load('collections', __DIR__.'/config/collections.php');
|
||||
Config::load('collections2', __DIR__.'/config/collections2.php');
|
||||
Config::load('runtimes', __DIR__.'/config/runtimes.php');
|
||||
Config::load('roles', __DIR__.'/config/roles.php'); // User roles and scopes
|
||||
Config::load('scopes', __DIR__.'/config/scopes.php'); // User roles and scopes
|
||||
|
@ -805,24 +804,6 @@ App::setResource('console', function() {
|
|||
]);
|
||||
}, []);
|
||||
|
||||
App::setResource('consoleDB', function($db, $cache) {
|
||||
$consoleDB = new DatabaseOld();
|
||||
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache));
|
||||
$consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects
|
||||
$consoleDB->setMocks(Config::getParam('collections', []));
|
||||
|
||||
return $consoleDB;
|
||||
}, ['db', 'cache']);
|
||||
|
||||
App::setResource('projectDB', function($db, $cache, $project) {
|
||||
$projectDB = new DatabaseOld();
|
||||
$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache));
|
||||
$projectDB->setNamespace('app_'.$project->getId());
|
||||
$projectDB->setMocks(Config::getParam('collections', []));
|
||||
|
||||
return $projectDB;
|
||||
}, ['db', 'cache', 'project']);
|
||||
|
||||
App::setResource('dbForInternal', function($db, $cache, $project) {
|
||||
$cache = new Cache(new RedisCache($cache));
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
|||
use Appwrite\Migration\Migration;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
Config::load('collections.old', __DIR__.'/../config/collections.old.php');
|
||||
|
||||
$cli
|
||||
->task('migrate')
|
||||
->param('version', APP_VERSION_STABLE, new Text(8), 'Version to migrate to.', true)
|
||||
|
@ -29,12 +31,12 @@ $cli
|
|||
$consoleDB
|
||||
->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache))
|
||||
->setNamespace('app_console') // Main DB
|
||||
->setMocks(Config::getParam('collections', []));
|
||||
->setMocks(Config::getParam('collections.old', []));
|
||||
|
||||
$projectDB = new Database();
|
||||
$projectDB
|
||||
->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache))
|
||||
->setMocks(Config::getParam('collections', []));
|
||||
->setMocks(Config::getParam('collections.old', []));
|
||||
|
||||
$console = $consoleDB->getDocument('console');
|
||||
|
||||
|
|
|
@ -1377,22 +1377,9 @@ class ProjectsConsoleClientTest extends Scope
|
|||
'store' => '',
|
||||
'hostname' => 'localhost',
|
||||
]);
|
||||
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'type' => 'web',
|
||||
// 'name' => 'Web App',
|
||||
// 'key' => '',
|
||||
// 'store' => '',
|
||||
// 'hostname' => 'https://localhost',
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -1402,7 +1389,9 @@ class ProjectsConsoleClientTest extends Scope
|
|||
public function testListProjectPlatform($data): array
|
||||
{
|
||||
$id = $data['projectId'] ?? '';
|
||||
|
||||
|
||||
sleep(1);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
|
@ -1424,7 +1413,7 @@ class ProjectsConsoleClientTest extends Scope
|
|||
public function testGetProjectPlatform($data): array
|
||||
{
|
||||
$id = $data['projectId'] ?? '';
|
||||
|
||||
|
||||
$platformWebId = $data['platformWebId'] ?? '';
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([
|
||||
|
|
|
@ -20,11 +20,11 @@ class CollectionsTest extends TestCase
|
|||
public function testDuplicateRules()
|
||||
{
|
||||
foreach ($this->collections as $key => $collection) {
|
||||
if (array_key_exists('rules', $collection)) {
|
||||
foreach ($collection['rules'] as $check) {
|
||||
if (array_key_exists('attributes', $collection)) {
|
||||
foreach ($collection['attributes'] as $check) {
|
||||
$occurences = 0;
|
||||
foreach ($collection['rules'] as $rule) {
|
||||
if ($rule['key'] == $check['key']) {
|
||||
foreach ($collection['attributes'] as $attribute) {
|
||||
if ($attribute['$id'] == $check['$id']) {
|
||||
$occurences++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue