1
0
Fork 0
mirror of synced 2024-10-03 02:37:40 +13:00
This commit is contained in:
shimon 2024-02-01 17:12:27 +02:00
parent 350d72eb1f
commit 030cdf3cc8
4 changed files with 18 additions and 14 deletions

2
.gitmodules vendored
View file

@ -1,4 +1,4 @@
[submodule "app/console"]
path = app/console
url = https://github.com/appwrite/console
branch = 3.2.16
branch = 1.5.x

View file

@ -56,7 +56,7 @@
"utopia-php/image": "0.6.*",
"utopia-php/locale": "0.4.*",
"utopia-php/logger": "0.3.*",
"utopia-php/messaging": "0.8.*",
"utopia-php/messaging": "0.9.*",
"utopia-php/migration": "0.3.*",
"utopia-php/orchestration": "0.9.*",
"utopia-php/platform": "0.5.*",

View file

@ -71,26 +71,29 @@ class V20 extends Migration
'console' => 'console',
default => 'projects',
};
$databases = $this->projectDB->find('databases', []);
foreach ($databases as $database) {
var_dump($database);
}
$collections = $this->collections[$collectionType];
foreach ($collections as $collection) {
$id = $collection['$id'];
Console::log("Migrating Collection \"{$id}\"");
$this->projectDB->setNamespace("_{$this->project->getInternalId()}");
$modifiedAttr = [];
$this->projectDB->setNamespace("_$internalProjectId");
// Support database array type migration
foreach ($collection['attributes'] ?? [] as $attribute) {
if ($attribute['type'] === 'string' && $attribute['array'] === true) {
$this->projectDB->updateAttribute($id, $attribute['$id']);
$modifiedAttr[] = $attribute['$id'];
}
}
if (!empty($modified)) {
foreach ($collection['indexes'] ?? [] as $index) {
$foundIndexes = array_intersect($modifiedAttr, $index['attributes']);
if ($foundIndexes) {
$this->projectDB->deleteIndex($id, $index['$id']);
if ($attribute['array'] === true) {
foreach ($collection['indexes'] ?? [] as $index) {
if (in_array($attribute['$id'], $index['attributes'])) {
$this->projectDB->deleteIndex($id, $index['$id']);
}
}
$this->projectDB->updateAttribute($id, $attribute['$id'], Database::VAR_STRING);
}
}

View file

@ -93,6 +93,7 @@ class Migrate extends Action
// TODO: Iterate through all project DBs
/** @var Database $projectDB */
$projectDB = $getProjectDB($project);
var_dump($project);
$migration
->setProject($project, $projectDB, $dbForConsole)
->setPDO($register->get('db', true))