mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 01:18:37 +00:00
Merge pull request #6076 from appwrite/fix-domains-migration
Fix domains migration
This commit is contained in:
commit
31bff542e9
1 changed files with 33 additions and 24 deletions
|
|
@ -10,6 +10,7 @@ use Utopia\Database\Database;
|
||||||
use Utopia\Database\DateTime;
|
use Utopia\Database\DateTime;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
use Utopia\Database\Exception;
|
use Utopia\Database\Exception;
|
||||||
|
use Utopia\Database\Query;
|
||||||
|
|
||||||
class V19 extends Migration
|
class V19 extends Migration
|
||||||
{
|
{
|
||||||
|
|
@ -33,6 +34,11 @@ class V19 extends Migration
|
||||||
Console::info('Migrating Collections');
|
Console::info('Migrating Collections');
|
||||||
$this->migrateCollections();
|
$this->migrateCollections();
|
||||||
|
|
||||||
|
if ($this->project->getId() == 'console') {
|
||||||
|
Console::info('Migrating Domains');
|
||||||
|
$this->migrateDomains();
|
||||||
|
}
|
||||||
|
|
||||||
Console::info('Migrating Buckets');
|
Console::info('Migrating Buckets');
|
||||||
$this->migrateBuckets();
|
$this->migrateBuckets();
|
||||||
|
|
||||||
|
|
@ -43,6 +49,33 @@ class V19 extends Migration
|
||||||
$this->cleanCollections();
|
$this->cleanCollections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function migrateDomains(): void
|
||||||
|
{
|
||||||
|
foreach ($this->documentsIterator('domains') as $domain) {
|
||||||
|
$status = 'created';
|
||||||
|
if ($domain->getAttribute('verification', false)) {
|
||||||
|
$status = 'verified';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ruleDocument = new Document([
|
||||||
|
'projectId' => $domain->getAttribute('projectId'),
|
||||||
|
'projectInternalId' => $domain->getAttribute('projectInternalId'),
|
||||||
|
'domain' => $domain->getAttribute('domain'),
|
||||||
|
'resourceType' => 'api',
|
||||||
|
'resourceInternalId' => '',
|
||||||
|
'resourceId' => '',
|
||||||
|
'status' => $status,
|
||||||
|
'certificateId' => $domain->getAttribute('certificateId'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->consoleDB->createDocument('rules', $ruleDocument);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("Error migrating domain {$domain->getAttribute('domain')}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrating all Bucket tables.
|
* Migrating all Bucket tables.
|
||||||
*
|
*
|
||||||
|
|
@ -611,30 +644,6 @@ class V19 extends Migration
|
||||||
$document->setAttribute('smtp', []);
|
$document->setAttribute('smtp', []);
|
||||||
$document->setAttribute('templates', []);
|
$document->setAttribute('templates', []);
|
||||||
|
|
||||||
break;
|
|
||||||
case 'rules':
|
|
||||||
$status = 'created';
|
|
||||||
if ($document->getAttribute('verification', false)) {
|
|
||||||
$status = 'verified';
|
|
||||||
}
|
|
||||||
|
|
||||||
$ruleDocument = new Document([
|
|
||||||
'projectId' => $this->project->getId(),
|
|
||||||
'projectInternalId' => $this->project->getInternalId(),
|
|
||||||
'domain' => $document->getAttribute('domain'),
|
|
||||||
'resourceType' => 'api',
|
|
||||||
'resourceInternalId' => '',
|
|
||||||
'resourceId' => '',
|
|
||||||
'status' => $status,
|
|
||||||
'certificateId' => $document->getAttribute('certificateId'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->consoleDB->createDocument('rules', $ruleDocument);
|
|
||||||
} catch (\Throwable $th) {
|
|
||||||
Console::warning("Error migrating domain {$document->getAttribute('domain')}: {$th->getMessage()}");
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue