mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
updates
This commit is contained in:
parent
a254bb7edb
commit
883cfedc46
2 changed files with 25 additions and 5 deletions
|
|
@ -72,9 +72,26 @@ class V20 extends Migration
|
||||||
default => 'projects',
|
default => 'projects',
|
||||||
};
|
};
|
||||||
|
|
||||||
$databases = $this->projectDB->find('databases', []);
|
// Support database array type migration (user collections)
|
||||||
foreach ($databases as $database) {
|
$attributes = $this->projectDB->find('attributes', [
|
||||||
var_dump($database);
|
Query::equal('array', [true]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
$indexes = $this->projectDB->find('indexes', [
|
||||||
|
Query::equal('databaseInternalId', [$attribute['databaseInternalId']]),
|
||||||
|
Query::equal('collectionInternalId', [$attribute['collectionInternalId']]),
|
||||||
|
]);
|
||||||
|
$foundIndex = 0;
|
||||||
|
foreach ($indexes as $index) {
|
||||||
|
if (in_array($attribute['key'], $index['attributes'])) {
|
||||||
|
$this->projectDB->deleteIndex($index['collectionId'], $index['_uid']);
|
||||||
|
$foundIndex = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($foundIndex === 1) {
|
||||||
|
$this->projectDB->updateAttribute($attribute['collectionInternalId'], $attribute['key'], Database::VAR_STRING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$collections = $this->collections[$collectionType];
|
$collections = $this->collections[$collectionType];
|
||||||
|
|
@ -86,14 +103,18 @@ class V20 extends Migration
|
||||||
$this->projectDB->setNamespace("_$internalProjectId");
|
$this->projectDB->setNamespace("_$internalProjectId");
|
||||||
|
|
||||||
// Support database array type migration
|
// Support database array type migration
|
||||||
|
$foundIndex = 0;
|
||||||
foreach ($collection['attributes'] ?? [] as $attribute) {
|
foreach ($collection['attributes'] ?? [] as $attribute) {
|
||||||
if ($attribute['array'] === true) {
|
if ($attribute['array'] === true) {
|
||||||
foreach ($collection['indexes'] ?? [] as $index) {
|
foreach ($collection['indexes'] ?? [] as $index) {
|
||||||
if (in_array($attribute['$id'], $index['attributes'])) {
|
if (in_array($attribute['$id'], $index['attributes'])) {
|
||||||
$this->projectDB->deleteIndex($id, $index['$id']);
|
$this->projectDB->deleteIndex($id, $index['$id']);
|
||||||
|
$foundIndex = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->projectDB->updateAttribute($id, $attribute['$id'], Database::VAR_STRING);
|
if ($foundIndex === 1) {
|
||||||
|
$this->projectDB->updateAttribute($id, $attribute['$id'], Database::VAR_STRING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ class Migrate extends Action
|
||||||
// TODO: Iterate through all project DBs
|
// TODO: Iterate through all project DBs
|
||||||
/** @var Database $projectDB */
|
/** @var Database $projectDB */
|
||||||
$projectDB = $getProjectDB($project);
|
$projectDB = $getProjectDB($project);
|
||||||
var_dump($project);
|
|
||||||
$migration
|
$migration
|
||||||
->setProject($project, $projectDB, $dbForConsole)
|
->setProject($project, $projectDB, $dbForConsole)
|
||||||
->setPDO($register->get('db', true))
|
->setPDO($register->get('db', true))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue